Last active
December 8, 2015 01:36
-
-
Save yaegaki/5544b85b37f76474fd8a to your computer and use it in GitHub Desktop.
[JavaScript]CryptoJSでAES暗号のsaltとパスフレーズからkeyを求める ref: http://qiita.com/yaegaki/items/9701317a76a35bea1684
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
var encrypted = CryptoJS.AES.encrypt('message', 'pass'); | |
console.log(encrypted.salt.toString()); // 467c08b2364309e8 | |
console.log(encrypted.key.toString()); // 6e475a9672994638c4231bd750ab7aceeb9004229f0a26c3622a2045deb789e9 |
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
var aesDecryptor = CryptoJS.algo.AES.createDecryptor(key, { iv: iv }); | |
var plaintextPart1 = aesDecryptor.process(ciphertextPart1); | |
var plaintextPart2 = aesDecryptor.process(ciphertextPart2); | |
var plaintextPart3 = aesDecryptor.process(ciphertextPart3); | |
var plaintextPart4 = aesDecryptor.process(ciphertextPart4); | |
var plaintextPart5 = aesDecryptor.finalize(); |
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
var key = CryptoJS.kdf.OpenSSL.execute(pass, 8, 4, salt).key; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment