当前位置: 首页>>代码示例>>C#>>正文


C# CipherMode.ToString方法代码示例

本文整理汇总了C#中CipherMode.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CipherMode.ToString方法的具体用法?C# CipherMode.ToString怎么用?C# CipherMode.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CipherMode的用法示例。


在下文中一共展示了CipherMode.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DontDecryptLastBlock

		// see bug #80439
		public void DontDecryptLastBlock (CipherMode mode, PaddingMode padding)
		{
			SymmetricAlgorithm algo = Algorithm;
			algo.Mode = mode;
			algo.Padding = padding;
			ICryptoTransform enc = algo.CreateEncryptor ();
			byte[] plaintext = new byte[BlockSize * 7];
			byte[] encdata = new byte[BlockSize * 8];
			int len = enc.TransformBlock (plaintext, 0, plaintext.Length, encdata, 0);
			Assert.AreEqual (plaintext.Length, len, "encdata");

			ICryptoTransform dec = algo.CreateDecryptor ();
			byte[] decdata = new byte[plaintext.Length];
			len = dec.TransformBlock (encdata, 0, encdata.Length, decdata, 0);
			Assert.AreEqual (plaintext.Length, len, "decdata");

			Assert.AreEqual (plaintext, decdata, "TransformBlock." + mode.ToString ());
		}
开发者ID:Profit0004,项目名称:mono,代码行数:19,代码来源:SymmetricAlgorithmTransformTest.cs

示例2: DontDecryptLastBlock_Final

		// see bug #80439 (2nd try, reopened)
		// same as DontDecryptLastBlock except
		// a. the encryption transform was final (padding was added)
		// b. we can call/test decryption TransformFinalBlock too
		public void DontDecryptLastBlock_Final (CipherMode mode, PaddingMode padding)
		{
			SymmetricAlgorithm algo = Algorithm;
			algo.Mode = mode;
			algo.Padding = padding;
			ICryptoTransform enc = algo.CreateEncryptor ();
			byte[] plaintext = new byte[BlockSize * 7];
			byte[] encdata = enc.TransformFinalBlock (plaintext, 0, plaintext.Length);
			switch (padding) {
			case PaddingMode.None:
			case PaddingMode.Zeros:
				Assert.AreEqual (BlockSize * 7, encdata.Length, "encdata");
				break;
			default:
				Assert.AreEqual (BlockSize * 8, encdata.Length, "encdata");
				break;
			}

			ICryptoTransform dec = algo.CreateDecryptor ();
			byte[] decdata = new byte[plaintext.Length];
			dec.TransformBlock (encdata, 0, encdata.Length, decdata, 0);

			Assert.AreEqual (plaintext, decdata, "TransformBlock." + mode.ToString ());

			dec = algo.CreateDecryptor ();
			byte[] final = dec.TransformFinalBlock (encdata, 0, encdata.Length);
			Assert.AreEqual (plaintext, final, "TransformFinalBlock." + mode.ToString ());
		}
开发者ID:Profit0004,项目名称:mono,代码行数:32,代码来源:SymmetricAlgorithmTransformTest.cs

示例3: BlowFishTransform

            public BlowFishTransform(byte[] key, byte[] iv, bool encrypt, bool isLittleEndian, CipherMode cipherMode, PaddingMode paddingMode)
            {
                switch (cipherMode)
                {
                    case CipherMode.CBC:
                    case CipherMode.ECB:
                        break;
                    default:
                        throw new NotSupportedException($"CipherMode {cipherMode.ToString()} is not supported.");
                }

                
                this.PaddingMode = paddingMode;
                this.IV = iv;
                this.IsEncryptor = encrypt;
                this.CipherMode = cipherMode;
                this.IsLittleEndian = isLittleEndian;
                this.CipherMode = CipherMode.ECB;
                this.SetupKey(key);
            }
开发者ID:badmishkallc,项目名称:GoDark,代码行数:20,代码来源:BlowFish.cs


注:本文中的CipherMode.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。