mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 11:06:33 +00:00
add scripts for cdn
change aes mode to cfb in encrypt / decrypt in Security
This commit is contained in:
@@ -19,10 +19,11 @@ public static class Security
|
||||
if (key is not { Length: > 0 }) throw new ArgumentNullException(nameof(key));
|
||||
|
||||
using var aes = Aes.Create();
|
||||
aes.Mode = CipherMode.CFB;
|
||||
aes.Key = SHA256.HashData(Encoding.UTF8.GetBytes(key));
|
||||
aes.GenerateIV();
|
||||
|
||||
using var encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
|
||||
|
||||
await using var cs = new CryptoStream(toStream, encryptor, CryptoStreamMode.Write, leaveOpen: true);
|
||||
|
||||
// Prepend IV to the encrypted data
|
||||
@@ -43,8 +44,9 @@ public static class Security
|
||||
var iv = new byte[aes.BlockSize / 8];
|
||||
_ = await encryptedStream.ReadAsync(iv, cancellationToken);
|
||||
aes.IV = iv;
|
||||
|
||||
aes.Mode = CipherMode.CFB;
|
||||
using var decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
|
||||
|
||||
await using var cryptoStream = new CryptoStream(encryptedStream, decryptor, CryptoStreamMode.Read, leaveOpen: true);
|
||||
|
||||
// Read and write in chunks
|
||||
|
||||
Reference in New Issue
Block a user