mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-12-14 22:54:32 +08:00
拆分数据处理分类,新增编码加密、数学计算分类
This commit is contained in:
48
plugin/lib/quickcomposer/coding/encoder.js
Normal file
48
plugin/lib/quickcomposer/coding/encoder.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const { dataConv } = require("./utils");
|
||||
|
||||
const encoder = {
|
||||
// base64 编码
|
||||
base64Encode: function (text) {
|
||||
return dataConv(text, "utf8", "base64");
|
||||
},
|
||||
// base64 解码
|
||||
base64Decode: function (text) {
|
||||
return dataConv(text, "base64", "utf8");
|
||||
},
|
||||
// URL 编码
|
||||
urlEncode: function (text) {
|
||||
return encodeURIComponent(text);
|
||||
},
|
||||
// URL 解码
|
||||
urlDecode: function (text) {
|
||||
return decodeURIComponent(text);
|
||||
},
|
||||
// html 编码
|
||||
htmlEncode: function (text) {
|
||||
return text
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
},
|
||||
// html 解码
|
||||
htmlDecode: function (text) {
|
||||
return text
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, "'");
|
||||
},
|
||||
// 十六进制
|
||||
hexEncode: function (text) {
|
||||
return dataConv(text, "utf8", "hex");
|
||||
},
|
||||
// 十六进制解码
|
||||
hexDecode: function (text) {
|
||||
return dataConv(text, "hex", "utf8");
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = encoder;
|
||||
Reference in New Issue
Block a user