DannyJio Posted May 24, 2016 Posted May 24, 2016 from Crypto.Cipher import AES from Crypto.Hash import SHA256 import argparse import sys from base64 import b64encode, b64decode def encrypt(value, cipher): return b64encode(cipher.encrypt(pkcs5_pad(value))) def pkcs5_pad(s): BLOCK_SIZE= 16 return s + (BLOCK_SIZE - len(s) ) * chr(BLOCK_SIZE - len(s) ) code = "higher_env3" code1 = "592174f17a037393" output = "hovkczsxXwdUVV7Ffciwig==" hashedkey = SHA256.new(code1).digest() print "hashedkey = %r" % hashedkey keycipher = AES.new(hashedkey, AES.MODE_ECB) print "keycipher = %r" % keycipher print(encrypt(code, keycipher))
rudi Posted May 24, 2016 Posted May 24, 2016 Hello, welcome to the forum. Have a look at the function _Crypt_HashData(), requires an "#include <Crypt.au3>". Some of the available hash function value codes are commented out, but work fine: ; crypt.au3 [snip] ; Global Const $CALG_SHA_256 = 0x0000800c ; Global Const $CALG_SHA_384 = 0x0000800d ; Global Const $CALG_SHA_512 = 0x0000800e [snip] Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE!
DannyJio Posted May 25, 2016 Author Posted May 25, 2016 (edited) I try to wrong output. #include <Crypt1.au3> #include "Base64.au3" Global $key = "592174f07a037393"; Global $str = "higher_env3" _Crypt_Startup() Local $hash = _Base64Encode(_Crypt_HashData($key, $CALG_SHA_256)) ConsoleWrite("hash = " & $hash & @CRLF) $hKey = _Crypt_DeriveKey($hash, $CALG_AES_256) $s = _Crypt_EncryptData($str, $hKey, $CALG_USERKEY) correct in python = mszw/K08roGSqb9X2kSMVQ== output autoit = QP8NYMgQxM19cP/sO+4/6w== Edited May 25, 2016 by DannyJio
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