Pass Span instead of Memory

This commit is contained in:
eelke 2026-02-26 20:39:48 +01:00
parent 650fe99990
commit ccc00d8e80
10 changed files with 45 additions and 38 deletions

View file

@ -12,7 +12,7 @@ public static class Encryption
new(1, 12, 16), // version 1
];
public static byte[] Encrypt(ReadOnlyMemory<byte> plaintext, ReadOnlySpan<byte> key)
public static byte[] Encrypt(ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> key)
{
const int versionNumber = 1;
AlgVersion versionParams = _versions[versionNumber];
@ -31,7 +31,7 @@ public static class Encryption
// use the spans to place the data directly in its place
RandomNumberGenerator.Fill(nonce);
using var aes = new AesGcm(key, versionParams.TagSize);
aes.Encrypt(nonce, plaintext.Span, cipher, tag);
aes.Encrypt(nonce, plaintext, cipher, tag);
return result;
}