php md5 algorithm that gives same result as c# -


I have a hashing algorithm in C #, in a nutshell, this is:

  string Input = "AD"; System.Security.Cryptography.MD5 alg = System.Security.Cryptography.MD5.Create (); System.Text.UTF8 encoding encoding = new system Text.UTF8Encoding (); Byte [] hash = elg Compact hash (enc. Gateboots); String Output = Convert. ToBase64String (hash); // output: eBVpbsvxyW5olLd5RW0zDg == console.light line (output);  

Now I need to repeat this behavior in php,

  $ input = "asd"; $ Output = hash ($ input); $ Echo output; Base64_encode  
  • Url_decode

    But I found that php does not get md5 = = finally ... what am I missing?

    Note : I can not change C # behavior as it is already implemented and password has been saved in my DB with this algorithm.

    The issue is PHP's md5 () function by default hex variation of hash Where C # is returning the raw byte output, which should secure the text with base 64 encoding. If you are running PHP5 then you can use the base64_encode (md5 ('asd', true)) . Note the second parameter of md5 () which returns the raw bytes instead of md5 () hex.


  • Comments

    Popular posts from this blog

    python - Overriding the save method in Django ModelForm -

    html - CSS autoheight, but fit content to height of div -

    qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -