import execjs
def _run_js(Str_start, keys): code = """ function decrypt(word, keys) { // 此处定义了一个js函数 const CryptoJS = require('crypto-js'); // 导入 crypto-js 加密、解密模块 const decrypted = CryptoJS.AES.decrypt(word, keys); # 开始解密 const plaintext = JSON.parse(decrypted.toString(CryptoJS.enc.Utf8)) # 最后将解密的内容,转换成json格式 return plaintext # 返回解密完成的数据 ==>> Json_string(调用函数) } """
decrypt_ = execjs.compile(code) Json_string = decrypt_.call("decrypt", Str_start, keys) return Json_string
string_ = "xxxxxxx" keys = "xxxxx" _run_js(string_, keys)
|