var btoa = function(ptr_callee, isConstructCall, ptrj_arguments, argumentCount, callbackState){ // ptr_callee不知道是什么 // isConstructCall表示是不是構(gòu)造方法 // ptrj_arguments是參數(shù)的數(shù)組 // argumentCount是參數(shù)的個數(shù) // callbackState也不知道是什么 var pointerSize = 4; var jStr = ..raw.convert(ptrj_arguments, {ptr p}, pointerSize).p; var aStr = ChakraCore.jValueToString(jStr); var result = crypt.bin.encodeBase64(aStr); var jResult = core.JsCreateString(result,#result,); return jResult; };
var atob = function(ptr_callee, isConstructCall, ptrj_arguments, argumentCount, callbackState){ var pointerSize = 4; var jStr = ..raw.convert(ptrj_arguments, {ptr p}, pointerSize).p; var aStr = ChakraCore.jValueToString(jStr); var result = crypt.bin.decodeBase64(aStr); var jResult = core.JsCreateString(result,#result,); return jResult; }
core.registerMethod(btoa, 'btoa'); core.registerMethod(atob, 'atob'); var result = core.run('btoa('Hello, world')') console.log('btoa: ', result) console.log('atob: ', core.callFunction('atob', result)) console.pause(true);
var js = /* let key = CryptoJS.enc.Utf8.parse('1234567890000000'); let iv = CryptoJS.enc.Utf8.parse('1234567890000000');
let s = 'Hello World'; let encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(s), key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
var eData = CryptoJS.enc.Base64.stringify(encrypted.ciphertext); console.log('加密字符串: ', eData);
let decrypted = CryptoJS.AES.decrypt(eData,key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }); let dData= decrypted.toString(CryptoJS.enc.Utf8).toString(); console.log('解密字符串: ', dData); */