shawenguan 2 years ago
parent
commit
b595338361
1 changed files with 10 additions and 1 deletions
  1. 10 1
      Scripts/thwj/thwjHelper.js

+ 10 - 1
Scripts/thwj/thwjHelper.js

@@ -210,9 +210,18 @@ function loadIndex() {
     });
 }
 
+function string2Hex(tmp) {
+    let str = '';
+    for (let i = 0; i < tmp.length; i++) {
+        str += tmp[i].charCodeAt(0).toString(16);
+    }
+    return str;
+}
+
 function base64encode(str) {
     let CryptoJS = createCryptoJS();
-    let data = CryptoJS.enc.Utf16.parse(str);
+    let hexStr = string2Hex(str);
+    let data = CryptoJS.enc.Hex.parse(hexStr);
     let base64Data = CryptoJS.enc.Base64.stringify(data);
     return 'data:image/png;base64,' + base64Data;
 }