Errata Conversione HMAC SHA256

Ciao a tutti ,

sto cercando di criptare una stringa con l’agoritmo HMAC SHA256

Stringa:
eyJhbGciOiJIUzI1NiIsIm1lc3NhZ2UiOiJKV1QifQ==.eyJpc3N1ZXIiOiIiLCJuYW1lIjoiYWRtaW5pc3RyYXRvciBhZG1pbmlzdHJhdG9yIiwidXNlcm5hbWUiOiJBZG1pbiJ9

Chiave:
lexis_key

Il codice utilizzato :

Dim conversione as String
conversione = Crypto.HMAC(key, stringa, Crypto.Algorithm.SHA256)

Il risutato che viene dato :

@!y kM3 uufN)Ƥ+VvQ

Secondo vari siti di conversione online (ad esempio freeformatter.com ) il risultato corretto :

a59e9c4557a8c72fc8c9407e94e5b309494cb9fc453d04ed37efce7291d979cc

Sto commettendo qualche errore?

Ho preso esempio dalla guida http://documentation.xojo.com/api/cryptography/crypto.html.HMAC

Grazie Mille

I don’t quite understand Italian :wink:
It seems to me that you want the Hex-String.
HMAC will return the “Binary value” (a “bag of Bytes” in a String).
So have a look at: EncodeHex.
Hex-Encode the result you get from HMAC.

Oh, Thanks. Now is OK.

Many thanks for your response. I wasn’t careful when I read the documentation.

Many thanks :wink: