3590dca32eba901dae88884d0be28d77a1d1b864.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, oops, StorageSecuritySimple, _crd;
  4. function _reportPossibleCrUseOfoops(extras) {
  5. _reporterNs.report("oops", "../../Oops", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfIStorageSecurity(extras) {
  8. _reporterNs.report("IStorageSecurity", "./StorageManager", _context.meta, extras);
  9. }
  10. _export("StorageSecuritySimple", void 0);
  11. return {
  12. setters: [function (_unresolved_) {
  13. _reporterNs = _unresolved_;
  14. }, function (_cc) {
  15. _cclegacy = _cc.cclegacy;
  16. }, function (_unresolved_2) {
  17. oops = _unresolved_2.oops;
  18. }],
  19. execute: function () {
  20. _crd = true;
  21. _cclegacy._RF.push({}, "386e3+fu+RJB5VSgow0kwS4", "StorageSecuritySimple", undefined);
  22. /**
  23. * 本地存储加密
  24. * 优点:
  25. * 1、代码体积小
  26. * 2、不依赖第三方库,使用这套方案可删除
  27. * StorageSecurityCrypto.ts
  28. * EncryptUtil.ts
  29. * package.json 中的crypto依赖减小包体
  30. *
  31. * 缺点:
  32. * 1、加密强度小
  33. */
  34. _export("StorageSecuritySimple", StorageSecuritySimple = class StorageSecuritySimple {
  35. constructor() {
  36. this.secretkey = null;
  37. var key = (_crd && oops === void 0 ? (_reportPossibleCrUseOfoops({
  38. error: Error()
  39. }), oops) : oops).config.game.localDataKey;
  40. var iv = (_crd && oops === void 0 ? (_reportPossibleCrUseOfoops({
  41. error: Error()
  42. }), oops) : oops).config.game.localDataIv;
  43. this.secretkey = key + iv;
  44. }
  45. encrypt(str) {
  46. var er = '';
  47. for (var i = 0; i < str.length; i++) {
  48. er += String.fromCharCode(str.charCodeAt(i) ^ this.secretkey.charCodeAt(i % this.secretkey.length));
  49. }
  50. return er;
  51. }
  52. decrypt(str) {
  53. var dr = '';
  54. for (var i = 0; i < str.length; i++) {
  55. dr += String.fromCharCode(str.charCodeAt(i) ^ this.secretkey.charCodeAt(i % this.secretkey.length));
  56. }
  57. return dr;
  58. }
  59. encryptKey(str) {
  60. return this.encrypt(str);
  61. }
  62. });
  63. _cclegacy._RF.pop();
  64. _crd = false;
  65. }
  66. };
  67. });
  68. //# sourceMappingURL=3590dca32eba901dae88884d0be28d77a1d1b864.js.map