Make Key with key size 128 - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:Key

Description

Make Key with key size 128

Demo Code


using System.Text;
using System.Security.Cryptography;
using System;/*from ww w .j  av  a2 s .  c  om*/
using Org.BouncyCastle.Utilities.Encoders;

public class Main{
        public static string MakeKey(int keySize = 128)
        {
            var aesCryptoServiceProvider = new AesCryptoServiceProvider();
            aesCryptoServiceProvider.KeySize = keySize;

            aesCryptoServiceProvider.GenerateKey();
            byte[] key = aesCryptoServiceProvider.Key;

            return Convert.ToBase64String(key);
        }
}

Related Tutorials