[Gambas-user] HMAC-MD5 & CRAM-MD5
mtitouinfo at yahoo.fr
mtitouinfo at yahoo.fr
Fri Jun 26 17:23:15 CEST 2020
Le jeudi 25 juin 2020 à 14:48:05 UTC+2, Tobias Boege --- a écrit :
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
----------
hi Tobias
:~$ gbs3 -u 'gb.openssl' -e 'Print Base64$(HMac("passwd", "challenge", "MD5"))'MMain.Main.5: #18: No return valueMMain.Main.5 :~$ gbs3 -u 'gb.openssl' -e 'Print Base64$(HMac("passwd", "challenge", "md5"))'MMain.Main.5: #18: No return valueMMain.Main.5 :~$ gbs3 -u 'gb.openssl' -e 'Print Base64$(HMac("passwd", "challenge"))'sbW1+7EULk2FR6c8iJMKcIWUcAc=
packet broken ?
:~$ apt show gambas3-gb-openssl Package: gambas3-gb-opensslVersion: 3.14.3+git6015.2a35dde+build5.a086335.13.3ac8a0c~ubuntu16.04.1Priority: optionalSection: libdevelSource: gambas3Maintainer: Sebastian Kulesz <sebikul at gmail.com>Installed-Size: 34,8 kBDepends: libc6 (>= 2.14), libssl1.0.0 (>= 1.0.0)Download-Size: 12,0 kBAPT-Manual-Installed: yesAPT-Sources: http://ppa.launchpad.net/gambas-team/gambas3/ubuntu xenial/main amd64 PackagesDescription: Gambas OpenSSL component
Bye. Titou.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200626/04f7c3d5/attachment.html>
More information about the User
mailing list