本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}