System.Utilities.Cryptography.Hash.Compute512Byte C# (CSharp) Метод

Compute512Byte() публичный статический Метод

Generates a 512-bit hash for the given data using the specified Salt value and returns the generated results as an array of bytes. If no salt value is given one is automatically used. (NOTE: The default salt value is static and should not be considered secure!)
public static Compute512Byte ( IEnumerable Data, IEnumerable Salt ) : byte[]
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.
Результат byte[]
        public static byte[] Compute512Byte(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 SHA512.ComputeHash(TD.ToArray());
        }

Same methods

Hash::Compute512Byte ( System Data ) : byte[]
Hash::Compute512Byte ( byte Data ) : byte[]
Hash::Compute512Byte ( string Data ) : byte[]

Usage Example

Пример #1
0
        //Computes an 192-bit Initialization Vector
        private static KeyData GenerateKeyIV192(byte[] Key)
        {
            // Generate the Initialization Vector.
            byte[] IVH = Hash.Compute512Byte(Key);
            var    IV  = new byte[Bits192];

            for (int i = 0; i < Bits192; i++)
            {
                IV[i] = IVH[i];
            }

            //Make sure the key is the proper length and fix it if needed.
            if (Key.Length != Bits192)
            {
                var TempKey = new List <byte>(Key);
                int c       = Bits192;
                while (TempKey.Count != Bits192)
                {
                    if (TempKey.Count < Bits192)
                    {
                        TempKey.Add(IVH[c++]);
                    }
                    else if (TempKey.Count > Bits192)
                    {
                        TempKey.RemoveAt(0);
                    }
                    else
                    {
                        break;
                    }
                    if (c > IVH.Length - 1)
                    {
                        c = Bits192;
                    }
                }
                Key = TempKey.ToArray();
            }

            var NK = new KeyData {
                Key = Key, IV = IV
            };

            return(NK);
        }