我正在为应用程序开发一个加载器(在 c# 中)。应用程序在进程中注入,应用程序在 java 中(不要问我如何注入:秘密(或不))。问题我需要 hwid 验证,因为我不希望每个人都可以访问我的应用程序。我得到了很多系统信息,但无法找到相同的 hasing 方法,我尝试了 md5 :
c# 中的结果:BA5A5938CF02B7BF8BB0D02E1ACFC738
java 中的结果:F08BEE49030E21420FC1E1FA4FFF46FC
我在谷歌上剪了这么多时间,但我没有找到其他适用于这两种语言的散列方法请帮助我
Java md5 代码:
public static String md5encrypt()
throws NoSuchAlgorithmException {
String password = "hello";
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(password.getBytes());
byte[] digest = md.digest();
String myHash = DatatypeConverter
.printHexBinary(digest).toUpperCase();
return myHash;
}
C# md5 代码:
public string CreateMD5Hash(string input)
{
// Step 1, calculate MD5 hash from input
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
// Step 2, convert byte array to hex string
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("X2"));
}
return sb.ToString();
}