예제 #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
예제 #2
0
        } // End Sub SetIV

        public static string GenerateKey()
        {
            byte[] bIV;
            byte[] bKey;

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

                bIV  = aes.IV;
                bKey = aes.Key;
                // aes.Clear();
            } // End Using aes

            return("IV: " + ByteArrayToHexString(bIV) + System.Environment.NewLine + "Key: " + ByteArrayToHexString(bKey));
        } // End Function GenerateKey