Beispiel #1
0
 private static void EncryptAndEmbedIv(Stream dataToEncrypt, byte[] key, Stream destination, byte[] salt)
 {
     byte[] iv = CryptoRandom.NextBytesStatic(16);
     Encrypt(new CryptoRequest
     {
         EmbedIV   = true,
         InData    = dataToEncrypt,
         OutData   = destination,
         IV        = iv,
         Key       = key,
         EmbedSalt = salt != null,
         Salt      = salt
     });
 }
Beispiel #2
0
 private static Task EncryptAndEmbedIvAsync(Stream dataToEncrypt, byte[] key, Stream destination, byte[] salt, ReportAndCancellationToken token = null)
 {
     byte[] iv = CryptoRandom.NextBytesStatic(16);
     return(EncryptAsync(new CryptoRequest
     {
         EmbedIV = true,
         InData = dataToEncrypt,
         OutData = destination,
         IV = iv,
         Key = key,
         EmbedSalt = salt != null,
         Salt = salt,
         Token = token
     }));
 }
Beispiel #3
0
 /// <summary>
 /// Generates the random salt.
 /// </summary>
 /// <returns></returns>
 public byte[] GenerateRandomSalt() => CryptoRandom.NextBytesStatic(SaltLengthInBytes);