public.js 788 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import CryptoJS from './crypto-js/crypto-js.js'
  2. const key = CryptoJS.enc.Utf8.parse('e56cs11a8480cd82');
  3. const iv = CryptoJS.enc.Utf8.parse('6e891d191fcv8eec');
  4. export default {
  5. Encrypt(text) {
  6. let srcs = CryptoJS.enc.Utf8.parse(text);
  7. let encrypted = CryptoJS.AES.encrypt(srcs, key, {
  8. iv: iv,
  9. mode: CryptoJS.mode.CBC,
  10. padding: CryptoJS.pad.Pkcs7 //ZeroPadding
  11. });
  12. return encrypted.toString();
  13. },
  14. user_skey() {
  15. try {
  16. const value = uni.getStorageSync('gxdd_story_v1');
  17. if (value) {
  18. // console.log(value);
  19. return value;
  20. }
  21. } catch (e) {
  22. // error
  23. }
  24. // uni.navigateTo({
  25. // url: '/pages/ucenter/login'
  26. // })
  27. return null;
  28. },
  29. user_skey_set(skey) {
  30. try {
  31. uni.setStorageSync('gxdd_story_v1', skey);
  32. } catch (e) {
  33. // error
  34. }
  35. }
  36. }