hash512 string

Hi there :slight_smile:

i tried this to get a sha512 hash:

[code] Dim hashed As String
hashed = Crypto.Hash(“test”, Crypto.Algorithm.SHA512)

msgbox hashed[/code]

so the msgbox shows me some crypted crap here, i tried it with system.debuglog but then xojo is crashing. Normally i should see this:

ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff

So whats going on here ? :slight_smile:

The function will return the raw bytes, not the hex representation of those bytes. Use EncodeHex for that.

  Dim hashed As String = _
    EncodeHex( Crypto.Hash("test", Crypto.Algorithm.SHA512) )
  
  msgbox hashed

You beat me by a second there Kem…

You might want to lowercase it as well if you need it in the “ee26…” format instead of “EE26…”.

[quote=278261:@Kem Tekinay]The function will return the raw bytes, not the hex representation of those bytes. Use EncodeHex for that.

[code]
Dim hashed As String = _
EncodeHex( Crypto.Hash(“test”, Crypto.Algorithm.SHA512) )

msgbox hashed
[/code][/quote]

thats the point :smiley: ty for this fast answer!