zet-lib 1.2.98 → 1.2.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Util.js +17 -0
- package/package.json +1 -1
package/lib/Util.js
CHANGED
|
@@ -1258,4 +1258,21 @@ Util.cleanString = (str = '') => {
|
|
|
1258
1258
|
return str.replaceAll('(', '').replaceAll(')', '').replaceAll('%', '').replaceAll('-', '')
|
|
1259
1259
|
}
|
|
1260
1260
|
|
|
1261
|
+
Util.encrypt = (str, key) => {
|
|
1262
|
+
const crypto = require('crypto')
|
|
1263
|
+
var encrypt = crypto.createCipheriv('des-ede3', key, '')
|
|
1264
|
+
var theCipher = encrypt.update(str, 'utf8', 'base64')
|
|
1265
|
+
theCipher += encrypt.final('base64')
|
|
1266
|
+
theCipher = theCipher.replaceAll('/', '55ter55')
|
|
1267
|
+
return theCipher
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
Util.decrypt = (str, key) => {
|
|
1271
|
+
const crypto = require('crypto')
|
|
1272
|
+
str = str.replaceAll('55ter55', '/')
|
|
1273
|
+
var decrypt = crypto.createDecipheriv('des-ede3', key, '')
|
|
1274
|
+
var s = decrypt.update(str, 'base64', 'utf8')
|
|
1275
|
+
return s + decrypt.final('utf8')
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1261
1278
|
module.exports = Util
|