Skip to content

Instantly share code, notes, and snippets.

@pottedmeat7
Created October 28, 2019 22:25
Show Gist options
  • Save pottedmeat7/4c12026df8e9dc895619930745e99327 to your computer and use it in GitHub Desktop.
Save pottedmeat7/4c12026df8e9dc895619930745e99327 to your computer and use it in GitHub Desktop.
Decrypt string using openssl key and ruby
require 'openssl'
require 'base64'
private_key_file = 'privkey.pem';
password = 'this phrase is the clue to unlock the encryption'
encrypted_string = ""
File.open(ARGV[0]).each_line do |line|
encrypted_string += line
end
private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file),password)
string = private_key.private_decrypt(Base64.decode64(encrypted_string))
puts string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment