示例#1
0
        }   // End Constructor

        public string GenerateKey()
        {
            string retValue = null;

            using (System.Security.Cryptography.Aes aes = System.Security.Cryptography.Aes.Create())
            {
                aes.GenerateKey();
                aes.GenerateIV();

                byte[] bIV  = aes.IV;
                byte[] bKey = aes.Key;
                aes.Clear();

                retValue = "IV: " + ByteArrayToHexString(bIV)
                           + System.Environment.NewLine
                           + "Key: " + ByteArrayToHexString(bKey);

                System.Array.Clear(bIV, 0, bIV.Length);
                System.Array.Clear(bKey, 0, bKey.Length);
                bIV  = null;
                bKey = null;
            } // End Using aes

            return(retValue);
        } // End Function GenerateKey