Bladeren bron

新增base64库

陈龙 2 maanden geleden
bovenliggende
commit
23f687547e
2 gewijzigde bestanden met toevoegingen van 125 en 0 verwijderingen
  1. 36 0
      src/Auman.PieceWage.UniApp/utils/base64.js
  2. 89 0
      src/Auman.PieceWage.UniApp/utils/oldbase64.js

+ 36 - 0
src/Auman.PieceWage.UniApp/utils/base64.js

@@ -0,0 +1,36 @@
+/**
+ * Base64加解码类
+ */
+class Base64 {
+    /**
+     * Base64编码
+     * @param {string} plaintext 明文
+     * @returns 密文
+     */
+    encode(plaintext) {
+        let res = '';
+
+        // 浏览器兼容
+        if (typeof btoa === 'function' && typeof unescape === 'function') {
+            res = btoa(unescape(encodeURIComponent(plaintext)));
+        }
+
+        return res;
+    }
+
+    /**
+     * Base64解码
+     * @param {string} cipherText 密文
+     * @returns 明文
+     */
+    decode(cipherText) {
+        let res = '';
+
+        // 浏览器兼容
+        if (typeof btoa === 'function' && typeof escape === 'function') {
+            res = decodeURIComponent(escape(atob(cipherText)));
+        }
+        return res;
+    }
+}
+export default new Base64();

File diff suppressed because it is too large
+ 89 - 0
src/Auman.PieceWage.UniApp/utils/oldbase64.js


Some files were not shown because too many files changed in this diff