How can I reproduce a SHA512 hash in C# that fits the PHP SHA512?

前端 未结 3 564
天涯浪人
天涯浪人 2021-01-05 05:02

The question is pretty much self-explanatory. I Googled many sites, many methods, tried many encodings, but I can\'t get it to match.

I\'m trying to make the string

3条回答
  •  不知归路
    2021-01-05 05:23

    BitConverter works just fine ...

    var testVal = "asdasd";
    var enc = new ASCIIEncoding();
    var bytes = enc.GetBytes( testVal );
    
    var sha = new SHA512Managed();
    var result = sha.ComputeHash( bytes );
    
    var resStr = BitConverter.ToString( result );
    var nodash = resStr.Replace( "-", "" );
    
    nodash.Dump();
    

    (Fixed for 512-bit hash, sorry :)

提交回复
热议问题