AES encryptor not working

妖精的绣舞 提交于 2019-12-02 08:20:07

Three options, all of which do the same thing,

Either call csEncrypt.Close() or use csEncrypt.FlushFinalBlock() to flush the encrypted data to the memory stream - call it before cipertext = msEncrypt.ToArray().

Or, move cipher = msEncrypt.ToArray(); return cipertext; outside the using block where you're writing to the crypto stream.

Note csEncrypt.Flush() which might be the first guess does nothing..

http://reflector.webtropy.com/default.aspx/DotNET/DotNET/8@0/untmp/whidbey/REDBITS/ndp/clr/src/BCL/System/Security/Cryptography/CryptoStream@cs/1/CryptoStream@cs

public override void Flush() 
{
     return;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!