封装海阔的rsa函数调用
This commit is contained in:
parent
e6e90c01c6
commit
40fc2bd525
13
doc/更新日志.md
13
doc/更新日志.md
@ -1,10 +1,21 @@
|
|||||||
###### 2023/10/04
|
###### 2023/10/04
|
||||||
- 关于rsa加解密的研究,js模块导入方式研究失败。请用蜜蜂壳子注入的函数实现
|
- [X] 关于rsa加解密的研究,js模块导入方式研究失败。请用蜜蜂壳子注入的函数实现
|
||||||
```js
|
```js
|
||||||
log(typeof(rsaX));
|
log(typeof(rsaX));
|
||||||
if(typeof(rsaX)=='function'){
|
if(typeof(rsaX)=='function'){
|
||||||
rsaX(mode, pub, encrypt, input, inBase64, key, outBase64)
|
rsaX(mode, pub, encrypt, input, inBase64, key, outBase64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
- [X] 3.9.48beta8内部封装了RSA相关加解密函数。用法为
|
||||||
|
```js
|
||||||
|
let data = base64Encode('你好');
|
||||||
|
let publicKey = 'dzyyds';
|
||||||
|
console.log(typeof (RSA.encode));
|
||||||
|
let encryptBase64Data = RSA.encode(data,publicKey);
|
||||||
|
log('encryptBase64Data:'+encryptBase64Data);
|
||||||
|
let str = RSA.decode(data,publicKey);
|
||||||
|
log('str:'+str);
|
||||||
```
|
```
|
||||||
|
|
||||||
###### 2023/10/03
|
###### 2023/10/03
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
3.9.48beta7
|
3.9.48beta8
|
||||||
30
libs/drpy.js
30
libs/drpy.js
@ -55,7 +55,7 @@ function pre(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
let rule = {};
|
let rule = {};
|
||||||
const VERSION = 'drpy1 3.9.48beta4 20231004';
|
const VERSION = 'drpy1 3.9.48beta8 20231004';
|
||||||
/** 已知问题记录
|
/** 已知问题记录
|
||||||
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
|
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
|
||||||
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
|
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
|
||||||
@ -434,6 +434,34 @@ function getCryptoJS(){
|
|||||||
return 'console.log("CryptoJS已装载");'
|
return 'console.log("CryptoJS已装载");'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 封装的RSA加解密类
|
||||||
|
const RSA = {
|
||||||
|
encode:function (data,key,option){
|
||||||
|
// log('encode');
|
||||||
|
if(typeof(rsaEncrypt)==='function'){
|
||||||
|
if(!option||typeof(option)!=='object'){
|
||||||
|
return rsaEncrypt(data,key);
|
||||||
|
}else{
|
||||||
|
return rsaEncrypt(data,key,option);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
decode:function (data,key,option){
|
||||||
|
// log('decode');
|
||||||
|
if(typeof(rsaDecrypt)==='function'){
|
||||||
|
if(!option||typeof(option)!=='object'){
|
||||||
|
return rsaDecrypt(data,key);
|
||||||
|
}else{
|
||||||
|
return rsaDecrypt(data,key,option);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取壳子返回的代理地址
|
* 获取壳子返回的代理地址
|
||||||
* @returns {string|*}
|
* @returns {string|*}
|
||||||
|
|||||||
2
libs/drpy.min.js
vendored
2
libs/drpy.min.js
vendored
File diff suppressed because one or more lines are too long
@ -34,8 +34,15 @@ function init_test(){
|
|||||||
// encryptor.setPublicKey(publicKey) // 设置公钥
|
// encryptor.setPublicKey(publicKey) // 设置公钥
|
||||||
// var str = encryptor.encrypt(text) // 对数据进行加密
|
// var str = encryptor.encrypt(text) // 对数据进行加密
|
||||||
// console.log("加密数据:" + str);
|
// console.log("加密数据:" + str);
|
||||||
log('rsax:'+typeof(rsax));
|
// log('rsax:'+typeof(rsax));
|
||||||
log('rsaX:'+typeof(rsaX));
|
// log('rsaX:'+typeof(rsaX));
|
||||||
|
// let data = base64Encode('你好');
|
||||||
|
// let publicKey = 'dzyyds';
|
||||||
|
// console.log(typeof (RSA.encode));
|
||||||
|
// let encryptBase64Data = RSA.encode(data,publicKey);
|
||||||
|
// log('encryptBase64Data:'+encryptBase64Data);
|
||||||
|
// let str = RSA.decode(data,publicKey);
|
||||||
|
// log('str:'+str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +67,7 @@ function pre(){
|
|||||||
|
|
||||||
let rule = {};
|
let rule = {};
|
||||||
let vercode = typeof(pdfl) ==='function'?'drpy2.1':'drpy2';
|
let vercode = typeof(pdfl) ==='function'?'drpy2.1':'drpy2';
|
||||||
const VERSION = vercode+' 3.9.48beta4 20231004';
|
const VERSION = vercode+' 3.9.48beta8 20231004';
|
||||||
/** 已知问题记录
|
/** 已知问题记录
|
||||||
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
|
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
|
||||||
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
|
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
|
||||||
@ -442,6 +449,34 @@ function getCryptoJS(){
|
|||||||
return 'console.log("CryptoJS已装载");'
|
return 'console.log("CryptoJS已装载");'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 封装的RSA加解密类
|
||||||
|
const RSA = {
|
||||||
|
encode:function (data,key,option){
|
||||||
|
// log('encode');
|
||||||
|
if(typeof(rsaEncrypt)==='function'){
|
||||||
|
if(!option||typeof(option)!=='object'){
|
||||||
|
return rsaEncrypt(data,key);
|
||||||
|
}else{
|
||||||
|
return rsaEncrypt(data,key,option);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
decode:function (data,key,option){
|
||||||
|
// log('decode');
|
||||||
|
if(typeof(rsaDecrypt)==='function'){
|
||||||
|
if(!option||typeof(option)!=='object'){
|
||||||
|
return rsaDecrypt(data,key);
|
||||||
|
}else{
|
||||||
|
return rsaDecrypt(data,key,option);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取壳子返回的代理地址
|
* 获取壳子返回的代理地址
|
||||||
* @returns {string|*}
|
* @returns {string|*}
|
||||||
|
|||||||
2
libs/drpy2.min.js
vendored
2
libs/drpy2.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user