12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import JSEncrypt from './jsencrypt'
- // import JSEncrypt from '../node_modules/jsencrypt/bin/jsencrypt.js'
- // 密钥对生成 http://web.chacuo.net/netrsakeypair
- const publicKey = `MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu5EcZCw8a2QAwGwuDk/d
- +AQDKwqye2OG73gKvoUCkH2H47XtUHw9MOGYtG44BXrh4KYM0YqZrZIPu4FZzFTs
- 0wAyhzAHRXray0l/kAfCHtI+A9bwqOwbtBFOrL2lOCuVHptEE+RPmO4v7UCGcYIK
- umb0/cOtvXAa0yM5V9kxrGXpavsLPsoB5kWQwnelW/mYyIEm4Rtvh9uKsTyfkb80
- cxJtQNlq1sOrh0dR0aSIdDGnqCrtsaNw19UBQtOe5JsdXSeZYff9vuT9lwtjvkta
- k4hI3IwtmR1STTVp8ZJ+6Oumu+QCDQvNGHzX5oBumiGPmDqPd2wyTnFsDPypc685
- MwIDAQAB`
- const privateKey = `MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC7kRxkLDxrZADA
- bC4OT934BAMrCrJ7Y4bveAq+hQKQfYfjte1QfD0w4Zi0bjgFeuHgpgzRipmtkg+7
- gVnMVOzTADKHMAdFetrLSX+QB8Ie0j4D1vCo7Bu0EU6svaU4K5Uem0QT5E+Y7i/t
- QIZxggq6ZvT9w629cBrTIzlX2TGsZelq+ws+ygHmRZDCd6Vb+ZjIgSbhG2+H24qx
- PJ+RvzRzEm1A2WrWw6uHR1HRpIh0MaeoKu2xo3DX1QFC057kmx1dJ5lh9/2+5P2X
- C2O+S1qTiEjcjC2ZHVJNNWnxkn7o66a75AINC80YfNfmgG6aIY+YOo93bDJOcWwM
- /KlzrzkzAgMBAAECggEAQaVK84BL8SYB4Va7U8T+IeR9m13WE7tEqaEw2XdB64IT
- wk2U7jtdSzNZt6RvtPNKBM7444mHuajKGsztucbrT/nctVXI5bdW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dq
- tsob57LKyjiUqJT+rG0F1UMhXX4Bhx0/itmTzoXMFg2x4gCLLDsse4OYSprsZFxY
- EZ1+TtYg/zZVCOPJk39N8mIX`
- // 加密
- function encrypt(txt) {
- const encryptor = new JSEncrypt()
- encryptor.setPublicKey(publicKey) // 设置公钥
- return encryptor.encrypt(txt) // 对需要加密的数据进行加密
- }
- // 解密
- function decrypt(txt) {
- const encryptor = new JSEncrypt()
- encryptor.setPrivateKey(privateKey)
- return encryptor.decrypt(txt)
- }
- export default {
- encrypt,
- decrypt
- }
|