Javascript-python RSA Encryption problem

Source: Internet
Author: User

The original is encrypted using Jsencrypt 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')        };

Want to use Python's library RSA to implement the same encryption:
name = ' ADAM_LBQ ' #input1
Password = ' 123456 ' #input2

My implementation code is as follows:

Coding:utf-8

Import RSA
name = ' ADAM_LBQ '
Password = ' 123456 '
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 am the analog landing to crawl content, hope is encrypted and JS encrypted content is the same, how to write ah?

Reply content:

The original is encrypted using Jsencrypt 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')        };

Want to use Python's library RSA to implement the same encryption:
name = ' ADAM_LBQ ' #input1
Password = ' 123456 ' #input2

My implementation code is as follows:

Coding:utf-8

Import RSA
name = ' ADAM_LBQ '
Password = ' 123456 '
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 am the analog landing to crawl content, hope is encrypted and JS encrypted content is the same, how to write ah?

Generate a pair of RSA public keys

If Git is installed,
Open git bash, enter ssh-keygen-t RSA

All the way back to the C drive after the user directory there is a. SSH directory, in the. pub file is the public key file, which is the Pub_key

Public key encryption, the private key is used to decrypt

About python the rsa encryption

Pycrypto and RSA Password Technical notes

  • 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.