I am using AesCng
to generate an encryption key using the code below:
using System;
using System.Security.Cryptography;
using System.Text;
namespace EncryptionTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Encoding.UTF8.GetString(GenerateKey()));
}
static byte[] GenerateKey()
{
using (AesCng cng = new AesCng())
{
cng.GenerateKey();
return cng.Key;
}
}
}
}
When I check the key in the console, its shown as r?▬?^?-?▲?ZQ^???♥$)??8w?f▬?[??
It looks like some characters are not getting resolved. Can someone help me understand what I am doing wrong?