So I was checking some implementations online and I noticed that some people use the following way to generate a key:
using (var random = RandomNumberGenerator.Create())
{
var key = new byte[32];
random.GetBytes(key);
}
While others use the generateKey method which is built in the AES class:
using (Aes myAes = Aes.Create())
{
myAes.GenerateKey();
var key = myAes.Key;
}
Both of them are in the System.Security.Cryptography library, just wondering if there is an actual difference between them and if yes which one should I go with?
Aucun commentaire:
Enregistrer un commentaire