You’ve forgot to state the correct question. As I can see from the Java code provided (reverse engineering), all you want is to have MD5 hash code (as a String) for a given file; if it’s your case, you want just to
- Create MD5 crypto
- Open the file
- Compute hash on file stream
- Represent hash (which is
Byte[]
) asString
.
The implementation could be
using System.IO;
using System.Security.Cryptography;
...
//TODO: it's very time to rename "sig" into something more readable
private static String sig(String fileName) {
using (MD5 md5Hash = MD5.Create()) {
using (FileStream stm = new FileStream(fileName, FileMode.Open)) {
return String.Concat(md5Hash
.ComputeHash(stm)
.Select(b => b.ToString("X2")));
}
}
}
2
solved Get the MD5 hash code (as a String) for a given file in C# [closed]