-
-
Save bnorton/8ec95e9be2cf97b91eaf to your computer and use it in GitHub Desktop.
Node cookie parser for Rails 4.1 json encypted cookies
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 parser = require('./parse-cookie'); | |
var cookie = "ZGhTbEhmUzZBYWhDSUwxY1FhSE1sNU50UnpZa0lCYnlUMjZXNUM0VWJNQ1VCS3hqQVRFNWh5eEllakE5STFtcmtCQm5sbXpJeGZjSFJKWGcvSStwL0NMMDlzRXpTOVZCd1h3L3poY0pnait0M3VEc3lnL1orcUVVdDFlUFRLWEZ2eXU1RmQ0c3ZKL2czWFlBb0Fwa3hQa3BFOGpQWmVlM0FxWjVyKzNja0NmQzZKRVIxUmpDalZiUjgvYUFDbzdDLS1WQlhpQzRnaW5XN2lqNGJ3eldVRGpBPT0--863d5f35812a0de3c02104cb96a7479650602942%3D%3D--9379ccf91a2d979516615948e1f310e72ddd6521", | |
params = { | |
base: 'fdb79a5ddfb30d9639ab15fb149712c6b783d2baa10ca07e0ababfab1453a7eb9d94b686799151c963af8a5c28571127c5a221615d14ba8fe863a720ed49a003', | |
salt: 'encrypted cookie', | |
signed_salt: 'signed encrypted cookie', | |
iterations: 1000, | |
keylen: 64 | |
}; | |
decryptor = parser(params); | |
message = decryptor(cookie, 'aes-256-cbc'); | |
console.log(message); | |
// => {"session_id":"717fdab32b88a55f09c853349f198ae5","rails":"awesome!","_csrf_token":"exj0VLeC4FzAfBTfDrCYMYuxD2cYzH9chf/U8PuK+E8="} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment