Created
July 20, 2017 17:57
-
-
Save paulocoutinhox/88ab7392f989524116a908b22b3b72e9 to your computer and use it in GitHub Desktop.
Decryptor demo using cryptojs
This file contains hidden or 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
| var fs = require('fs'); | |
| var CryptoJS = require("crypto-js"); | |
| // ruby key encoded Base64 | |
| const key = CryptoJS.enc.Base64.parse("6LMmbmbL4EKvi55WJFxZHW5FOH25/RGbuD3Vx8MEYGU="); | |
| // ruby iv encoded Base64 | |
| const iv = CryptoJS.enc.Base64.parse("N9mT3Z5DzqghlBVBC0YsTg=="); | |
| console.log("-------------------------------------------------------------------------"); | |
| console.log("KEY: "); | |
| console.log("-------------------------------------------------------------------------"); | |
| //console.log(key); | |
| console.log(key.toString()); | |
| console.log(CryptoJS.enc.Base64.stringify(key).toString()); | |
| //console.log(CryptoJS.enc.Base64.stringify(key)); | |
| console.log("-------------------------------------------------------------------------"); | |
| console.log("IV: "); | |
| console.log("-------------------------------------------------------------------------"); | |
| //console.log(iv); | |
| console.log(iv.toString()); | |
| console.log(CryptoJS.enc.Base64.stringify(iv).toString()); | |
| //console.log(CryptoJS.enc.Base64.stringify(iv)); | |
| // conteúdo | |
| console.log("-------------------------------------------------------------------------"); | |
| console.log("CONTEUDO: "); | |
| console.log("-------------------------------------------------------------------------"); | |
| var content = fs.readFileSync('structure.js', 'utf8'); | |
| //console.log(content); | |
| // decriptografar | |
| var decrypted = CryptoJS.AES.decrypt(content, key, {iv: iv}) | |
| decrypted = decrypted.toString(CryptoJS.enc.Utf8); | |
| console.log(decrypted); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment