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


C# Aes.GenerateIV方法代码示例

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


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

示例1: AesCrypt

 public AesCrypt()
 {
     aes = Aes.Create();
     aes.Mode = CipherMode.CBC;
     aes.GenerateIV();
     aes.GenerateKey();
     aes.Padding = PaddingMode.PKCS7;
 }
开发者ID:eoftedal,项目名称:PoetAndDidntKnowIt,代码行数:8,代码来源:AesCrypt.cs

示例2: SimpleAes

        public SimpleAes(byte[] key)
        {
            aes = Aes.Create();
            aes.GenerateIV();

            aes.Key = key;

            encryptor = aes.CreateEncryptor(key, aes.IV);
            decryptor = aes.CreateDecryptor(key, aes.IV);
        }
开发者ID:jafnharr,项目名称:cryptkeeper,代码行数:10,代码来源:SimpleAes.cs

示例3: SetResponseVerifier

 private void SetResponseVerifier(Response r, Aes aes)
 {
     aes.GenerateIV();
     r.Nonce = encode64(aes.IV);
     r.Verifier = CryptoTransform(r.Nonce, false, true, aes, CMode.ENCRYPT);
 }
开发者ID:jaketyler,项目名称:keepasshttp,代码行数:6,代码来源:Protocol.cs

示例4: WriteMessageStream

        public static void WriteMessageStream(MemoryStream outStream, Message outMessage, string sessionKey, Aes aes, bool encrypt)
        {
            outMessage.ReplaceControlValue(Message.TimestampControlValueName, DateTime.Now.ToUniversalTime().ToString());
            outMessage.ReplaceControlValue(Message.SessionKeyControlValueName, sessionKey);
            if (encrypt)
            {
                aes.GenerateIV();

                StreamUtilities.WriteStringToMemoryStream(outStream, aes.IV.Length + "!");
                outStream.Write(aes.IV, 0, aes.IV.Length);
                StreamUtilities.RunCryptoTransform(outMessage.Serialize(), aes.CreateEncryptor(), outStream, true);
            }
            else
            {
                outMessage.Serialize(outStream);
            }
        }
开发者ID:Mavtak,项目名称:WebCommunicator,代码行数:17,代码来源:Common.cs

示例5: TestGenerate

	public static bool TestGenerate(Aes aes)
	{
		byte[] key = aes.Key;
		byte[] IV = aes.IV;

		aes.GenerateKey();
		aes.GenerateIV();

		if (aes.Key.Length != 32)
		{
			Console.WriteLine("Error - Aes.GenerateKey wrong length: {0}", aes.Key.Length);
			return false;
		}

		if (aes.IV.Length != 16)
		{
			Console.WriteLine("Error - Aes.GenerateIV wrong length: {0}", aes.IV.Length);
			return false;
		}

		if (CompareBytes(aes.Key, key))
		{
			Console.WriteLine("Error - Aes.GenerateKey did not change key");
			return false;
		}

		if (CompareBytes(aes.IV, IV))
		{
			Console.WriteLine("Error - Aes.GenerateIV did not change IV");
			return false;
		}

		return true;
	}
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:34,代码来源:AESAPI.cs


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