System.Utilities.Cryptography.Encryption.GenerateKeyIV256 C# (CSharp) Method

GenerateKeyIV256() private static method

private static GenerateKeyIV256 ( byte Key ) : KeyData
Key byte
return KeyData
        private static KeyData GenerateKeyIV256(byte[] Key)
        {
            // Generate the Initialization Vector.
            byte[] IVH = Hash.Compute512Byte(Key);
            var IV = new byte[Bits256];
            for (int i = 0; i < Bits256; i++)
                IV[i] = IVH[i];

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

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