How could I create the following PHP code in C# ?
Php code:
<?php
$salt = "salt";
$value = "hello";
$password_hashed = md5($salt.$value);
?>
I would appreciate any kind of help. Been testing the following:
https://stackoverflow.com/a/1300927/7312781
But it would only return a wrong string.
var salt = System.Text.Encoding.UTF8.GetBytes("salt");
var value = System.Text.Encoding.UTF8.GetBytes("hello");
var hmacMD5 = new HMACMD5(salt);
var saltedHash = hmacMD5.ComputeHash(value);
string hex = BitConverter.ToString(saltedHash);
MessageBox.Show(hex.Replace("-", ""));
Response: https://gyazo.com/340fe77979c1b0b531d07a8050ce66d1
The response should look like: 06decc8b095724f80103712c235586be
Hope this will help, it's some modification from given link
class Program {
static void Main(string[] args) {
var provider = MD5.Create();
string salt = "S0m3R@nd0mSalt";
string password = "SecretPassword";
byte[] bytes = provider.ComputeHash(Encoding.ASCII.GetBytes(salt + password));
string computedHash = BitConverter.ToString(bytes);
Console.WriteLine(computedHash.Replace("-", ""));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With