在java脚本中加密查询字符串并在python中解密

时间:2015-07-31 12:41:05

标签: javascript python encryption aes encryption-symmetric

我想在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()

0 个答案:

没有答案