Created
May 22, 2017 18:35
-
-
Save dwendt/f2eeae6d92eccb6cc3404fc245fe1d0c to your computer and use it in GitHub Desktop.
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' | |
SEED = 'EB3452127614E25A' | |
strings = ["TWMQJJtbRUD5FJur/SuWmW53rumcHkzZGS6TqK3CTvM=", "ZGG8VSEQSeJL45huJFIl3oLX0UE5tVlchKvXsGdYprQ=", "HybRUpUK8tXT0++qaOX+vNYYclDJsx2gBfLFc8j8N34=", "g4YT2OoY8qIG0M7BzrKI7CJMwv2KzVFBlAuSsZByErA="] | |
encryptedString = "g4YT2OoY8qIG0M7BzrKI7CJMwv2KzVFBlAuSsZByErA=" | |
def decrypt(cpass) | |
blockSize = 16; | |
rawBinary = Base64.decode64(cpass); | |
# IV is always the first block | |
ivBytes = rawBinary[0...blockSize]#arraySlice(rawBinary, 1, blockSize); | |
# Remaining bytes are the encrypted value | |
dataBytes = rawBinary[blockSize..-1]#arraySlice(rawBinary, blockSize+1, arrayLen(rawBinary)-blockSize); | |
des = OpenSSL::Cipher::Cipher.new('AES-128-CBC') | |
des.decrypt | |
des.key = SEED | |
des.iv = ivBytes | |
return des.update(dataBytes) + des.final | |
end | |
strings.each do |s| | |
decrypted = decrypt(s) | |
puts "#{decrypted}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment