我想在JavaScript&中加密queryString。解密Python, 这是一个pyhon代码,在JavaScript中需要类似的功能,所以我可以从JS&在python中解密。 或者如果你有其他办法解决这个问题......帮助
def encode(key, msg):
from Crypto.Cipher import AES
import base64
key = key.ljust(len(key) + (16 - len(key) % 16))
msg = msg.ljust(len(msg) + (16 - len(msg) % 16))
cipher = AES.new(key, AES.MODE_ECB)
return base64.b64encode(cipher.encrypt(msg))
def decode(key, msg):
from Crypto.Cipher import AES
import base64
key = key.ljust(len(key) + (16 - len(key) % 16))
cipher = AES.new(key, AES.MODE_ECB)
return (cipher.decrypt(base64.b64decode(msg))).strip()