Created
December 10, 2008 18:05
-
-
Save mdp/34425 to your computer and use it in GitHub Desktop.
This file contains 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
# OpenSSL RSA Cipher | |
# I always forget this, time to write it down | |
require "openssl" | |
require "base64" | |
private_key = OpenSSL::PKey::RSA.new(1024) | |
key = OpenSSL::PKey::RSA.new(private_key.public_key) | |
p enc = Base64.encode64(key.public_encrypt('mums the word')) | |
key = OpenSSL::PKey::RSA.new(private_key) | |
p key.private_decrypt(Base64.decode64(enc)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment