Last active
December 12, 2015 03:58
-
-
Save ecto/4710544 to your computer and use it in GitHub Desktop.
Challenge derivation test
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
| // include CryptoJS | |
| var message = '12345678901234567890123456789012'; | |
| var iv = CryptoJS.enc.Utf8.parse('1234567890123456'); | |
| var challengeKey = 'fe8844b73775265aef8839bf39de68a5aec6b0f447034472e8ff937bd9046e91'; | |
| var key = CryptoJS.enc.Hex.parse(challengeKey); | |
| var challenge = CryptoJS.AES.encrypt(message, key, { | |
| mode: CryptoJS.mode.CFB, | |
| iv: iv | |
| }).ciphertext.toString(); | |
| var decrypted = CryptoJS.AES.decrypt(challenge, key, { | |
| mode: CryptoJS.mode.CFB, | |
| iv: iv | |
| }).toString(); | |
| console.log(challenge); | |
| // f4c445b91f04ee1c2bed0d84396470a2be086d624012b000ec69496dca47f62ba6b305f693545a2785533091bfb54f76 | |
| // length: 96 | |
| console.log(decrypted); | |
| // length: 0 |
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 crypto = require('crypto'); | |
| var message = new Buffer('12345678901234567890123456789012', 'utf8'); | |
| var iv = new Buffer('1234567890123456', 'utf8'); | |
| var challengeKey = 'fe8844b73775265aef8839bf39de68a5aec6b0f447034472e8ff937bd9046e91'; | |
| var key = new Buffer(challengeKey, 'hex'); | |
| var challengeCipher = crypto.createCipheriv('aes-256-cfb', key, iv); | |
| var challenge = challengeCipher.update(message, 'utf8', 'hex'); | |
| console.log(challenge); | |
| // ec022879aca6b53bc73d3a4d3a8ad1e2feb2e27d8c237384d4713504952b9fdd | |
| // length: 64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment