Last active
March 16, 2023 20:32
-
-
Save joecliff/10948592 to your computer and use it in GitHub Desktop.
cryptojs WordArray usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* cryptojs use WordArray (CryptoJS.lib.WordArray) as parameter/result frequently. | |
* A WordArray object represents an array of 32-bit words. When you pass a string, | |
* it's automatically converted to a WordArray encoded as UTF-8. | |
*/ | |
var CryptoJS = require("crypto-js"); | |
// convert String to WordArray | |
var wordArray = CryptoJS.enc.Utf8.parse('Hello, World!'); | |
// convert WordArray To String | |
var result1=wordArray.toString(CryptoJS.enc.Utf8); | |
var result2=CryptoJS.enc.Utf8.stringify(wordArray); | |
console.log(result1); | |
console.log(result1===result2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gamelife 1314
CryptoJS.enc.Hex.parse()