Originally, jsencrypt was used in HTML for encryption: varencryptnewJSEncrypt (); {code ...} to use the Python Library rsa for the same encryption: name & #039; Adam_LBQ & #039; # input1password & #039; 123456 & #039; # input2 my implementation code: coding: utf-8i...
Originally, jsencrypt was used for encryption in HTML:
Var encrypt = new JSEncrypt ();
encrypt.setPublicKey('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCp0wHYbg/NOPO3nzMD3dndwS0MccuMeXCHgVlGOoYyFwLdS24Im2e7YyhB0wrUsyYf0/nhzCzBK8ZC9eCWqd0aHbdgOQT6CuFQBMjbyGYvlVYU2ZP7kG9Ft6YV6oc9ambuO7nPZh+bvXH0zDKfi02prknrScAKC0XhadTHT3Al0QIDAQAB'); var encrypted_input1 = encrypt.encrypt($('#input1').val()); var encrypted_input2 = encrypt.encrypt($('#input2').val()); var ajax_data = { input1: encrypted_input1, input2: encrypted_input2, remember: $('#remember_me').prop('checked') };
We want to use the Python Library rsa to implement the same encryption:
Name = 'Adam _ lbq' # input1
Password = '000000' # input2
My implementation code is as follows:
Coding: UTF-8
Import rsa
Name = 'Adam _ lbq'
Password = '000000'
Pub_key = #? How to write?
Rsa_name = rsa. encrypt (name, pub_key)
Rsa_password = rsa. encrypt (password, pub_key)
Print rsa_name + '\ n' + rsa_password
I simulated login to crawl the content, hoping that the encrypted content is the same as that encrypted by js. How can I write it?
Reply content:
Originally, jsencrypt was used for encryption in HTML:
Var encrypt = new JSEncrypt ();
encrypt.setPublicKey('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCp0wHYbg/NOPO3nzMD3dndwS0MccuMeXCHgVlGOoYyFwLdS24Im2e7YyhB0wrUsyYf0/nhzCzBK8ZC9eCWqd0aHbdgOQT6CuFQBMjbyGYvlVYU2ZP7kG9Ft6YV6oc9ambuO7nPZh+bvXH0zDKfi02prknrScAKC0XhadTHT3Al0QIDAQAB'); var encrypted_input1 = encrypt.encrypt($('#input1').val()); var encrypted_input2 = encrypt.encrypt($('#input2').val()); var ajax_data = { input1: encrypted_input1, input2: encrypted_input2, remember: $('#remember_me').prop('checked') };
We want to use the Python Library rsa to implement the same encryption:
Name = 'Adam _ lbq' # input1
Password = '000000' # input2
My implementation code is as follows:
Coding: UTF-8
Import rsa
Name = 'Adam _ lbq'
Password = '000000'
Pub_key = #? How to write?
Rsa_name = rsa. encrypt (name, pub_key)
Rsa_password = rsa. encrypt (password, pub_key)
Print rsa_name + '\ n' + rsa_password
I simulated login to crawl the content, hoping that the encrypted content is the same as that encrypted by js. How can I write it?
Generate a pair of RSA public/private keys
If git is installed
Open git bash and enter ssh-keygen-t rsa
After you press enter, There Is A. ssh directory under the user directory on drive C. The. pub file is the public key file, that is, the pub_key here.
Public key encryption. The private key is used for decryption.
AboutpythonOfrsaEncryption
Pycrypto and RSA cryptographic technology notes