# python3 -m pip install pycryptodome
import base64
import hashlib
import hmac
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
key, iv = b'1234567890123456', b'abcdefghijklmnop'
cipher = base64.b64encode(AES.new(key, AES.MODE_CBC, iv).encrypt(pad('hello 世界'.encode('utf-8'), 16))).decode('ascii')
print(cipher)  # YL28tnUQb4uWoJRf3jGP5g==
plain = AES.new(key, AES.MODE_CBC, iv).decrypt(base64.b64decode(cipher))
print(unpad(plain, 16).decode('utf-8'))
print(hmac.new(b'my-secret', b'appid=10086', hashlib.sha256).hexdigest())
