0

我正在使用这个简洁的库(https://code.google.com/p/crypto-js/#AES)来加密我的消息。

从以下示例 AES 示例中:

<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>

<script>
    var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");
</script>

当我document.write(encrypted)它返回:

"U2FsdGVkX18W1n0wES5YsBzpRoRB1iu2KqzQiUSe6zE="

这就是我想要的。但是当我console.log(encrypted)它返回:


{ init: [Function], '$super': { init: [Function], toString: [Function], '$super': { extend: [Function], create: [Function], init: [Function], mixIn :[函数],克隆:[函数]}},密文:{字:[-463593157,-130193625,475395301,1812962665,-1322700187,433662359,1675036770,-337777864],密钥:初始化字节:32} [Function],'$super':{ init:[Function],toString:[Function],concat:[Function],clamp:[Function],克隆:[Function],随机:[Function],'$super' : [对象] }, 词: [ -1836471768, 609934685, -835470701,413762839,1279413942,-1961507681,-1590403020,392722880,2059661770,1403440185,1364381326,1364381326,1252361221] Function], concat: [Function],clamp: [Function], clone: [Function], random: [Function], '$super': [Object] }, words: [2059661770, 1403440185, 1364381326, 1252361221], sigBytes :16 },算法:{ _doReset:[Function],encryptBlock:[Function],decryptBlock:[Function],_doCryptBlock:[Function],keySize:8,init:[Function],'$super':{cfg:[对象],重置:[功能],_doProcessBlock: [Function], _doFinalize: [Function], blockSize: 4, init: [Function], '$super': [Object] } }, 模式: { init: [Function], '$super': { createEncryptor: [Function], createDecryptor: [Function], init: [Function], '$super': [Object] }, Encryptor: { processBlock: [Function], init: [Function], '$super': [Circular] } , Decryptor: { processBlock: [Function], init: [Function], '$super': [Circular] } }, padding: { pad: [Function], unpad: [Function] }, blockSize: 4, formatter: {字符串化:[函数],解析:[函数]},盐:{词:[359292117,-310439037],sigBytes:8}}_doFinalize: [Function], blockSize: 4, init: [Function], '$super': [Object] } }, 模式: { init: [Function], '$super': { createEncryptor: [Function], createDecryptor: [Function], init: [Function], '$super': [Object] }, Encryptor: { processBlock: [Function], init: [Function], '$super': [Circular] }, Decryptor: { processBlock: [Function], init: [Function], '$super': [Circular] } }, padding: { pad: [Function], unpad: [Function] }, blockSize: 4, formatter: { stringify: [Function],解析:[函数]},盐:{词:[359292117,-310439037],sigBytes:8}}_doFinalize: [Function], blockSize: 4, init: [Function], '$super': [Object] } }, 模式: { init: [Function], '$super': { createEncryptor: [Function], createDecryptor: [Function], init: [Function], '$super': [Object] }, Encryptor: { processBlock: [Function], init: [Function], '$super': [Circular] }, Decryptor: { processBlock: [Function], init: [Function], '$super': [Circular] } }, padding: { pad: [Function], unpad: [Function] }, blockSize: 4, formatter: { stringify: [Function],解析:[函数]},盐:{词:[359292117,-310439037],sigBytes:8}}'$super': [对象] } }, 模式: { init: [Function], '$super': { createEncryptor: [Function], createDecryptor: [Function], init: [Function], '$super': [对象] },加密器:{ processBlock:[Function],init:[Function],'$super':[Circular]},解密器:{ processBlock:[Function],init:[Function],'$super':[ Circular] } }, padding: { pad: [Function], unpad: [Function] }, blockSize: 4, formatter: { stringify: [Function], parse: [Function] }, salt: { words: [ 359292117, - 310439037], sigBytes: 8 } }'$super': [对象] } }, 模式: { init: [Function], '$super': { createEncryptor: [Function], createDecryptor: [Function], init: [Function], '$super': [对象] },加密器:{ processBlock:[Function],init:[Function],'$super':[Circular]},解密器:{ processBlock:[Function],init:[Function],'$super':[ Circular] } }, padding: { pad: [Function], unpad: [Function] }, blockSize: 4, formatter: { stringify: [Function], parse: [Function] }, salt: { words: [ 359292117, - 310439037], sigBytes: 8 } }init: [Function], '$super': [Object] }, Encryptor: { processBlock: [Function], init: [Function], '$super': [Circular] }, Decryptor: { processBlock: [Function], init: [Function], '$super': [Circular] } }, padding: { pad: [Function], unpad: [Function] }, blockSize: 4, formatter: { stringify: [Function], parse: [Function ] },盐:{ 字:[ 359292117,-310439037 ],sigBytes:8 } }init: [Function], '$super': [Object] }, Encryptor: { processBlock: [Function], init: [Function], '$super': [Circular] }, Decryptor: { processBlock: [Function], init: [Function], '$super': [Circular] } }, padding: { pad: [Function], unpad: [Function] }, blockSize: 4, formatter: { stringify: [Function], parse: [Function ] },盐:{ 字:[ 359292117,-310439037 ],sigBytes:8 } }[Function]},blockSize:4,格式化程序:{ stringify:[Function],解析:[Function]},salt:{words:[359292117,-310439037],sigBytes:8}}[Function]},blockSize:4,格式化程序:{ stringify:[Function],解析:[Function]},salt:{words:[359292117,-310439037],sigBytes:8}}


为什么两种方法都返回不同的结果以及如何使console.log表现得像document.write

4

1 回答 1

2

我想到了。原来它就像console.log(encrypted.toString());一样简单。

于 2013-08-28T03:21:52.380 回答