在Java中,MD5 MessageDigest 可以更新 Digest 比如// Get MD5 encryption algorithm
slgorithm = MessageDigest.getInstance("MD5");// Add the uid and seed to the algorithm
algorithm.reset();
algorithm.update(byte[]1);
algorithm.update(byte[]2);// Create byte array equal to MD5( uid + seed )
digest = algorithm.digest();
但在C#中,好像没有类似update这样的方法,可以同时对多个对象(String, byte[]. etc.) 进行MD5 Hash 比如public static byte[] generateMD5Digest(byte[] target)
{
byte[] digest;
MD5 md5 = MD5.Create();
digest = md5.ComputeHash(target); // 想对多个byte[]对象进行MD5 Hash
return digest;
}
期待高人的指引。
slgorithm = MessageDigest.getInstance("MD5");// Add the uid and seed to the algorithm
algorithm.reset();
algorithm.update(byte[]1);
algorithm.update(byte[]2);// Create byte array equal to MD5( uid + seed )
digest = algorithm.digest();
但在C#中,好像没有类似update这样的方法,可以同时对多个对象(String, byte[]. etc.) 进行MD5 Hash 比如public static byte[] generateMD5Digest(byte[] target)
{
byte[] digest;
MD5 md5 = MD5.Create();
digest = md5.ComputeHash(target); // 想对多个byte[]对象进行MD5 Hash
return digest;
}
期待高人的指引。
byte[] b1 = {1,2};
byte[] b2 = Encoding.Unicode.GetBytes("hello world"); MD5 md5 = MD5.Create();
md5.TransformBlock(b1, 0, b1.Length, b1, 0);
md5.TransformFinalBlock(b2, 0, b2.Length);
byte[] digest = md5.Hash;
Cool! thanks in bundle!