-4

So I have a website for my game

This is an exert of the php that I am using.

$Login = strtolower(trim($Login));
$Pass = strtolower(trim($Pass));
$Repass = strtolower(trim($Repass));

$Salt = $Login.$Pass;
$Salt = md5($Salt);
$Salt = "0x".$Salt;

But now I am faced with an issue that I cant seem to work out. I need to be able to do this encryption through C# WinForms for a client side Launcher(Register, Play Game etc etc)

For the life of me I cant figure out how to make the same binary as it makes in php.

I have tried loads but just cant crack it.

Many thanks if you can help

4

1 回答 1

2

尽管您的示例代码混淆了实际问题,但我认为我有解决您实际问题的方法。

我在使用该方法时遇到了同样的问题,md5()不久前将一些 PHP 代码转换为 C#。这是我想出的:

private static string CalculateChecksum(string inputString)
{
    var md5 = new MD5CryptoServiceProvider();
    var hashbytes = md5.ComputeHash(Encoding.UTF8.GetBytes(inputString));
    var hashstring = "";
    foreach(var hashbyte in hashbytes)
        hashstring += hashbyte.ToString("x2");

    return hashstring;
}

可能有一个更整洁的解决方案,但它对我有用,当时我很着急。

无论如何,它给你的字符串就像你对'sA48EDF06 ...所期望的那样phpmd5()

于 2012-10-29T10:32:59.857 回答