Python calls the JS method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.