Interface test process encountered the DES encryption problem, with Python study for a long time did not succeed, finally find the front end to DES encryption JS method, so study a bit
Here are the steps:
1, first installation can also be PIP installation
Post-installation code is as follows
ImportExecjsdefget_des_psswd (data, key): Jsstr=get_js () ctx=execjs.compile (jsstr) #加载JS文件return(Ctx.call ('Strenc', data, key)) #调用js方法 The first parameter is the JS method name, the following data and key are the parameters of the JS methoddefGet_js (): F= Open ("./.. /lib/des.js",'R', encoding='Utf-8') # Open JS file line=f.readline () htmlstr="' whileLine:htmlstr= htmlstr+ Line Line=F.readline ()returnHtmlstrif __name__=='__main__': Print(GET_DES_PSSWD ('123456','ruy2otdcruffrtg0ouq0q0e0odndrdmxn0yzoeezrequdg9ty2f0otq='))
Python calls the JS method