Skip to content

Instantly share code, notes, and snippets.

@dwendt
Created May 22, 2017 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwendt/f2eeae6d92eccb6cc3404fc245fe1d0c to your computer and use it in GitHub Desktop.
Save dwendt/f2eeae6d92eccb6cc3404fc245fe1d0c to your computer and use it in GitHub Desktop.
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