Last active
June 5, 2016 13:44
-
-
Save halan/c283507c8baf7a96beb9af12b153d53b to your computer and use it in GitHub Desktop.
This small ruby can decrypt AES-CBC encrypted at https://jsfiddle.net/kq8Lfpar/7/
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
require 'openssl' | |
require 'base64' | |
puts 'Go to https://jsfiddle.net/kq8Lfpar/7/ and encrypt some text for decrypt here' | |
print 'Password: ' | |
password = gets.chomp | |
print 'Encrypted: ' | |
encrypted = gets.chomp | |
salt, iv, cipher = encrypted.split('.').map{|s| Base64.decode64(s) } | |
key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(password, salt, 100, 256) | |
aes = OpenSSL::Cipher::Cipher.new('AES-256-CBC') | |
aes.decrypt | |
aes.key = key | |
aes.iv = iv | |
print aes.update(cipher) | |
puts aes.final |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment