[Gambas-user] HMAC-MD5 & CRAM-MD5
Tobias Boege
taboege at gmail.com
Thu Jun 25 14:47:04 CEST 2020
On Thu, 25 Jun 2020, mtitouinfo--- via User wrote:
> hellohow to translate this function, in native gambas, with component gb.openssl, without "Shell" ? thanks.
> gambas version: 3.14.3
> Private Function CramMD5(email As String, password As String, challenge As String) As String
> 'ok it works
> Dim token As String System.shell = "/bin/bash" Shell "awk '{print $NF}' < <(openssl dgst -hex -md5 -hmac " & password & " < <(openssl base64 -d <<<" & challenge & "))" To token token = Base64(Trim(email & " " & token))
> Return token End
echo -n challenge | openssl dgst -binary -md5 -hmac passwd | base64
> FaMyMCJdxjKw3+gJd96a+g==
Print Base64$(HMac("passwd", "challenge", "MD5"))
> FaMyMCJdxjKw3+gJd96a+g==
Note that your shell substitutions such as <<<"" may add newlines to your
data. I explicitly use `echo -n` here to show that the outputs can match
when you're careful enough about that.
Regards,
Tobias
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list