Created
January 15, 2019 02:12
-
-
Save AFlowOfCode/f375643dda799204921876cb19799f08 to your computer and use it in GitHub Desktop.
Revisions
-
AFlowOfCode created this gist
Jan 15, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ def decrypt_cookie(cookie, app_secret) token_hashed = OpenSSL::PKCS5.pbkdf2_hmac_sha1(app_secret, 'encrypted cookie', 1000, 32) encrypted_message = Base64.decode64(cookie).split('--')[0] decoded_cookie = Base64.strict_decode64(encrypted_message) cipher = OpenSSL::Cipher.new('aes-256-cbc') cipher.key = token_hashed decrypted_data = cipher.update(decoded_cookie) decrypted_data end