crypt.js 659 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * @Description: 本地数据加密解密
  3. * @Author: sql
  4. * @Date: 2018-11-23 20:38:06
  5. * @LastEditTime: 2018-11-29 16:14:16
  6. */
  7. import CryptoJs from 'crypto-js'
  8. class CryptToJS {
  9. constructor() {
  10. this.crypt = CryptoJs
  11. this.secret = 'Believe in yourself.'
  12. }
  13. // 加密内容, 原文
  14. Encrypt(text) {
  15. return this.crypt.AES.encrypt(text, this.secret).toString()
  16. }
  17. // 解密,加密内容
  18. Decrypt(text) {
  19. if (text == null || text.lenth == 0) {
  20. return ""
  21. }
  22. return this.crypt.AES.decrypt(text, this.secret).toString(CryptoJs.enc.Utf8)
  23. }
  24. }
  25. export default new CryptToJS