I have this code in C# that uses IKVM to utilize Java's SHA1 encryption.
public static string ComputeHash(params byte[][] bytes)
{
if (bytes == null) throw new ArgumentNullException("bytes");
MessageDigest digest = MessageDigest.getInstance("SHA-1");
foreach (var item in bytes)
{
if (item == null)
if (bytes == null) throw new ArgumentNullException("bytes", "Inner array is null");
digest.update(item);
}
string s = (new java.math.BigInteger(digest.digest())).toString(16);
return s;
}
Is there an alternative rather than using IKVM for this?
If I understand the question correctly, you could use the Sha1CryptoServiceProvider class in System.Security.Cryptography.
Here's the code example from that page:
byte[] data = new byte[DATA_SIZE];
byte[] result;
SHA1 sha = new SHA1CryptoServiceProvider();
// This is one implementation of the abstract class SHA1.
result = sha.ComputeHash(data);
I would not expect it to be too hard to change that example into one that takes jagged arrays.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.