Keltset Posted January 15, 2016 Share Posted January 15, 2016 (edited) Hello Everyone!I have a PHP script that I am trying to convert into AutoIt and have a silly question. Can anyone help me out in converting this one line into AutoIt?The following is the PHP code that works// Sign the request $signature = hash_hmac("sha256", $string_to_sign, $SECRET_ACCESS_KEY, TRUE); // Base64 encode the signature and make it URL safe $signature = urlencode(base64_encode($signature));I'm trying to figure out how to do this in AutoIt. I found two functions here: https://www.autoitscript.com/forum/topic/165093-funnot-with-hashing-sha256/?do=findComment&comment=1205352 But I cant seem to figure out how to get this to work or get my results to match what the above php code will put out...If there is anyone out there that can show me how to do this I would be forever in your debt! Thanks for the time in reviewing my problem. Edited January 15, 2016 by Keltset -K Link to comment Share on other sites More sharing options...
Jfish Posted January 15, 2016 Share Posted January 15, 2016 There is a base64 UDF, referenced here: https://www.autoitscript.com/forum/topic/107501-simple-base64-encoderdecoder/There is a crypt UDF in the standard help file (used in the example you cited).Can you post what you have tried so far and be more specific about what is not working? Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
Danyfirex Posted January 15, 2016 Share Posted January 15, 2016 I made a mod of a function from this thread (because I don't like "call" funtionhttps://www.autoitscript.com/forum/topic/165093-funnot-with-hashing-sha256/?do=findComment&comment=1205352 #include <Crypt.au3> Global Const $CALG_SHA_256 = 0x0000800c ConsoleWrite(hmac_sha256("message", "key") & @CRLF) Func hmac_sha256($message, $key) Local $blocksize = 64 Local $a_opad[$blocksize], $a_ipad[$blocksize] Local Const $oconst = 0x5C, $iconst = 0x36 Local $opad = Binary(''), $ipad = Binary('') $key = Binary($key) If BinaryLen($key) > $blocksize Then $key = _Crypt_HashData($key, $CALG_SHA_256) For $i = 1 To BinaryLen($key) $a_ipad[$i - 1] = Number(BinaryMid($key, $i, 1)) $a_opad[$i - 1] = Number(BinaryMid($key, $i, 1)) Next For $i = 0 To $blocksize - 1 $a_opad[$i] = BitXOR($a_opad[$i], $oconst) $a_ipad[$i] = BitXOR($a_ipad[$i], $iconst) Next For $i = 0 To $blocksize - 1 $ipad &= Binary('0x' & Hex($a_ipad[$i], 2)) $opad &= Binary('0x' & Hex($a_opad[$i], 2)) Next Return StringMid(_Crypt_HashData($opad & _Crypt_HashData($ipad & Binary($message), $CALG_SHA_256), $CALG_SHA_256), 3) EndFunc ;==>hmac_sha256Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now