public static Compute256Byte ( IEnumerable |
||
Data | IEnumerable |
The data to be hashed. Takes an array of bytes. |
Salt | IEnumerable |
The salt value used to help prevent dictionary attacks. Takes an array of bytes. |
return | byte[] |
//Computes an 128-bit Initialization Vector private static KeyData GenerateKeyIV128(byte[] Key) { // Generate the Initialization Vector. byte[] IVH = Hash.Compute256Byte(Key); var IV = new byte[Bits128]; for (int i = 0; i < Bits128; i++) { IV[i] = IVH[i]; } //Make sure the key is the proper length and fix it if needed. if (Key.Length != Bits128) { var TempKey = new List <byte>(Key); int c = Bits128; while (TempKey.Count != Bits128) { if (TempKey.Count < Bits128) { TempKey.Add(IVH[c++]); } else if (TempKey.Count > Bits128) { TempKey.RemoveAt(0); } else { break; } if (c > IVH.Length - 1) { c = Bits128; } } Key = TempKey.ToArray(); } var NK = new KeyData { Key = Key, IV = IV }; return(NK); }