encryption.js 540 B

123456789101112131415161718
  1. const CryptoJS = require('./crypot')
  2. const STR = 'XX#$%()(#*!()!KL<><MQLMNQNQJQK&sdfkjsdrow32234545fdf>?N<:{LWPW'
  3. function strToHexCharCode(str) {
  4.   if(str === "")
  5.     return "";
  6.   var hexCharCode = [];
  7.   hexCharCode.push("0x");
  8.   for(var i = 0; i < str.length; i++) {
  9.     hexCharCode.push((str.charCodeAt(i)).toString(16));
  10.   }
  11.   return hexCharCode.join("");
  12. }
  13. export function encryption (value) {
  14. const time = new Date().getTime()
  15. return CryptoJS.SHA256(`${value}${STR}${time}`).toString()
  16. }