本文整理汇总了C#中RijndaelManaged.GenerateIV方法的典型用法代码示例。如果您正苦于以下问题:C# RijndaelManaged.GenerateIV方法的具体用法?C# RijndaelManaged.GenerateIV怎么用?C# RijndaelManaged.GenerateIV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RijndaelManaged
的用法示例。
在下文中一共展示了RijndaelManaged.GenerateIV方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateEncryptionVector
/// Generates a unique encryption vector
public static byte[] GenerateEncryptionVector()
{
//Generate a Vector
RijndaelManaged rm = new RijndaelManaged();
rm.GenerateIV();
return rm.IV;
}
示例2: Main
static void Main(string[] args)
{
using (var rijndael = new RijndaelManaged())
using (var hmacsha256 = new HMACSHA256())
{
rijndael.GenerateKey();
rijndael.GenerateIV();
hmacsha256.Initialize();
Console.WriteLine(template, new SoapHexBinary(rijndael.Key), new SoapHexBinary(rijndael.IV), new SoapHexBinary(hmacsha256.Key));
}
Console.WriteLine("press any key to exit...");
Console.ReadKey();
}
示例3: CreateRijndaelIv
// create Rijndael initialization vector
private static byte[] CreateRijndaelIv()
{
byte[] rijndaelIv;
using (var myRijndael = new RijndaelManaged())
{
myRijndael.Mode = CipherMode.CBC;
myRijndael.KeySize = 256;
myRijndael.BlockSize = 256;
myRijndael.Padding = PaddingMode.Zeros;
myRijndael.GenerateIV();
rijndaelIv = myRijndael.IV;
}
return rijndaelIv;
}
示例4: EncryptMessage
public static string EncryptMessage(byte[] text, string key)
{
RijndaelManaged aes = new RijndaelManaged();
aes.KeySize = 256;
aes.BlockSize = 256;
aes.Padding = PaddingMode.Zeros;
aes.Mode = CipherMode.CBC;
aes.Key = Encoding.Default.GetBytes(key);
aes.GenerateIV();
string IV = ("-[--IV-[-" + Encoding.Default.GetString(aes.IV));
ICryptoTransform AESEncrypt = aes.CreateEncryptor(aes.Key, aes.IV);
byte[] buffer = text;
return Convert.ToBase64String(Encoding.Default.GetBytes(Encoding.Default.GetString(AESEncrypt.TransformFinalBlock(buffer, 0, buffer.Length)) + IV));
}