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[] |
public static byte[] Compute256Byte(IEnumerable<byte> Data, IEnumerable<byte> Salt)
{
var TD = new List<byte>(Data);
var TS = new List<byte>(Salt);
//The Salt Algorithm
TD.AddRange(TS);
foreach (byte b in TS)
{
TD.Insert(0, b);
TD.Insert(TD.Count - 1, b);
}
return SHA256.ComputeHash(TD.ToArray());
}
Hash::Compute256Byte ( System Data ) : byte[] | |
Hash::Compute256Byte ( byte Data ) : byte[] | |
Hash::Compute256Byte ( string Data ) : 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); }