Skip to content

Instantly share code, notes, and snippets.

@timakin
Created October 5, 2016 06:54
Show Gist options
  • Save timakin/1cb97f4ea9f1be5d28de9618feeec74c to your computer and use it in GitHub Desktop.
Save timakin/1cb97f4ea9f1be5d28de9618feeec74c to your computer and use it in GitHub Desktop.
decrypt private key in ruby
#!/usr/bin/env ruby
# DECRYPT
require 'openssl'
require 'base64'
private_key_file = 'private.pem';
password = 'boost facile'
encrypted_string = %Q{
...
}
private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file),password)
string = private_key.private_decrypt(Base64.decode64(encrypted_string))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment