#433 address breaking change in aes api in net 6

https://github.com/dotnet/runtime/issues/55527
This commit is contained in:
Eliot Jones
2022-04-03 15:13:45 -04:00
parent 9be57c6948
commit 347259eaa5
2 changed files with 10 additions and 8 deletions

View File

@@ -23,7 +23,9 @@ namespace UglyToad.PdfPig.Tests.Encryption
var output = AesEncryptionHelper.Decrypt(data, key); var output = AesEncryptionHelper.Decrypt(data, key);
Assert.Equal("D:20180808103317-07'00'", OtherEncodings.BytesAsLatin1String(output)); var actual = OtherEncodings.BytesAsLatin1String(output);
Assert.Equal("D:20180808103317-07'00'", actual);
} }
} }
} }

View File

@@ -35,16 +35,16 @@
input.Seek(iv.Length, SeekOrigin.Begin); input.Seek(iv.Length, SeekOrigin.Begin);
using (var cryptoStream = new CryptoStream(input, decryptor, CryptoStreamMode.Read)) using (var cryptoStream = new CryptoStream(input, decryptor, CryptoStreamMode.Read))
{ {
var offset = 0;
int read; int read;
while ((read = cryptoStream.Read(buffer, 0, buffer.Length)) != -1) do
{ {
output.Write(buffer, 0, read); read = cryptoStream.Read(buffer, offset, buffer.Length - offset);
if (read < buffer.Length) output.Write(buffer, offset, read);
{
break; offset += read;
} } while (read > 0);
}
return output.ToArray(); return output.ToArray();
} }