原来是在HTML中使用jsencrypt来加密:
var encrypt = new JSEncrypt();
<code> 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') }; </code>
想用Python的库rsa来实现同样的加密:
name = 'Adam_LBQ'#input1
password = '123456' #input2
我的实现代码如下:
import rsa
name = 'Adam_LBQ'
password = '123456'
pub_key = #?怎么写啊
rsa_name = rsa.encrypt(name,pub_key)
rsa_password = rsa.encrypt(password,pub_key)
print rsa_name +'\n'+ rsa_password
我是模拟登陆来爬去内容的,希望是加密之后和js加密的内容是一样的,该怎么写啊?
原来是在HTML中使用jsencrypt来加密:
var encrypt = new JSEncrypt();
<code> 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') }; </code>
想用Python的库rsa来实现同样的加密:
name = 'Adam_LBQ'#input1
password = '123456' #input2
我的实现代码如下:
import rsa
name = 'Adam_LBQ'
password = '123456'
pub_key = #?怎么写啊
rsa_name = rsa.encrypt(name,pub_key)
rsa_password = rsa.encrypt(password,pub_key)
print rsa_name +'\n'+ rsa_password
我是模拟登陆来爬去内容的,希望是加密之后和js加密的内容是一样的,该怎么写啊?
生成一对RSA的公私钥
如果装了git
打开git bash,输入ssh-keygen -t rsa
一路回车后在c盘用户目录下面有个.ssh目录,进去.pub文件就是公钥文件,也就是这里的pub_key
公钥加密,私钥则用来解密
关于 python
的 rsa
加密
Pycrypto与RSA密码技术笔记