作者:雪恝1988_757 | 来源:互联网 | 2024-09-30 17:44
Icurrentlyhaveafunction[C#]whichtakesabyte[]andanalignmenttosetitto,butduringencr
I currently have a function [C#] which takes a byte[] and an alignment to set it to, but during encryption, an error is thrown every once in awhile.
我目前有一个函数[C#],它接受一个byte []和一个对齐来设置它,但在加密过程中,每隔一段时间就抛出一个错误。
private byte[] AlignByteArray(byte[] content, int alignto)
{
long thelength = content.Length - 1;
long remainder = 1;
while (remainder != 0)
{
thelength += 1;
remainder = thelength % alignto;
}
Array.Resize(ref content, (int)thelength);
return content;
}
Does anyone see any issues with the function? I'm getting errors that the content size is not valid during AES encryption, suggesting that it is not padding right.
有没有人看到该功能有任何问题?我收到的错误是AES加密期间内容大小无效,表明它没有正确填充。
2 个解决方案