我正在将我的一个库移动到 Xamarin PLC。
官方文档指出支持 System.Security.Cryptography 命名空间,但在实际代码中并不支持。
我正在寻找一种在没有此命名空间的情况下计算 SHA256 哈希的方法(并且在 Windows 命名空间中没有 HashAlgorithmProvider。此方法会破坏 Android 和 WP8.0 的应用程序)
最佳答案
使用 Bouncy CaSTLe PCL 库 (https://www.nuget.org/packages/Portable.BouncyCastle/) 测试类似的东西
var encData = Encoding.UTF8.GetBytes("TESTHASH");
Org.BouncyCastle.Crypto.Digests.Sha256Digest myHash = new Org.BouncyCastle.Crypto.Digests.Sha256Digest();
myHash.BlockUpdate (encData, 0, encData.Length);
byte[] compArr = new byte[myHash.GetDigestSize ()];
myHash.DoFinal (compArr, 0);
关于c# - 在没有 System.Security.Cryptography 的情况下计算 SHA256 哈希,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36464840/