Generate a 64 bits Key - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:Password

Description

Generate a 64 bits Key

Demo Code


using System.Text;
using System.Security.Cryptography;

public class Main{
        // Function to Generate a 64 bits Key.
        public static string GenerateKey()
        {/*  w  w  w.  java 2s .co m*/
            // Create an instance of Symetric Algorithm. Key and IV is generated automatically.
            // AesCryptoServiceProvider aesCrypto = (AesCryptoServiceProvider)AesCryptoServiceProvider.Create();
            Aes aesCrypto = System.Security.Cryptography.Aes.Create();

            // Use the Automatically generated key for Encryption. 
            return ASCIIEncoding.ASCII.GetString(aesCrypto.Key);
        }
}

Related Tutorials