mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-06-04 00:19:33 +08:00
添加对String 加密与解密
This commit is contained in:
32
DncryptDemo/assets/Script/HelloWorld.js
Normal file
32
DncryptDemo/assets/Script/HelloWorld.js
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
const encrypt = require('encryptjs');
|
||||
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
label: {
|
||||
default: null,
|
||||
type: cc.Label
|
||||
},
|
||||
// defaults, set visually when attaching this script to the Canvas
|
||||
text: 'Hello, World!'
|
||||
},
|
||||
|
||||
// use this for initialization
|
||||
onLoad: function () {
|
||||
this.label.string = this.text;
|
||||
let abc = 'aaaaaaaaaaa';
|
||||
let key = 'key';
|
||||
let encryStr = encrypt.encrypt(abc, key, 256);
|
||||
console.log('abc=', encryStr);
|
||||
|
||||
let decryStr = encrypt.decrypt(encryStr, key, 256);
|
||||
console.log('abc', decryStr);
|
||||
},
|
||||
|
||||
// called every frame
|
||||
update: function (dt) {
|
||||
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user