Created
October 28, 2019 22:25
-
-
Save pottedmeat7/4c12026df8e9dc895619930745e99327 to your computer and use it in GitHub Desktop.
Decrypt string using openssl key and ruby
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' | |
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