How to convert Ruby's SHA512.hexdigest to C#? -
i'm re-writing rails web app in c#. i'm stuck ruby's hash function:
# generates 128 character hash def password.hash(password,salt) digest::sha512.hexdigest("#{password}:#{salt}") end
the following c# function gives different result:
private static string hash(string password, string salt) { return bitconverter.tostring(new sha512cryptoserviceprovider().computehash(encoding.utf8.getbytes(password + ":" + salt))).replace("-", "").tolower(); }
what doing wrong?
thank you
never mind. results are same. if ever need convert ruby's hashing c#,
digest::sha512.hexdigest(some_string)
does same
bitconverter.tostring(new sha512cryptoserviceprovider().computehash(encoding.utf8.getbytes(somestring))).replace("-", "").tolower();
c# lot more verbose, main thing works! :)
Comments
Post a Comment