problems with Crypto.PBKDF2

I’ve got a function where I encrypt my Mac serial number
a is the sent variable…

Dim sh As New Shell
Dim s As String
Dim x As Integer
sh.execute “/usr/sbin/ioreg -l | /usr/bin/grep IOPlatformSerialNumber”
If x>0 Then s=replaceall(Trim(Mid(s,x+1)),chr(34),"")
If s="" Then s=“no serial number”
s = Crypto.PBKDF2(a, s, 100, 32, Crypto.Algorithm.SHA512)
return s

I’m getting this here string


which does not look like a good hash.
I can’t use it for anything actually!

what am i doing wrong?


s = encodehex(Crypto.PBKDF2(a, s, 100, 32, Crypto.Algorithm.SHA512))

I will do!

To clarify, that function returns raw bytes. You can try to look at it as a string, but that’s meaningless. Encoding as hex lets you see the byte values in a meaningful way and store it without worrying about text encoding.

Exactly, Kem is correct. What you got previously is working as intended. Also, keep in mind that there are 2-hex characters for every one-byte (00-FF), so your hex return will be 2x the length you specified in the pbkdf2 (or any other crypto algorithm call).

Actually, I like it - I was having problem sending the original encoding as a webservice parameter. After hours of testing and trying, I realized that sending the original string was causing my app to go into a crash (very frustrating). so this solution is really cool :slight_smile: It has no problem sending this new example (thanks a bunch :))