Created
June 9, 2012 21:44
-
-
Save emboss/2902696 to your computer and use it in GitHub Desktop.
Revisions
-
emboss created this gist
Jun 9, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ require 'openssl' require 'base64' rsa = OpenSSL::PKey::RSA.new(2048) modulus = rsa.n exponent = rsa.e ary = [OpenSSL::ASN1::Integer.new(modulus), OpenSSL::ASN1::Integer.new(exponent)] pub_key = OpenSSL::ASN1::Sequence.new(ary) base64 = Base64.encode64(pub_key.to_der) #This is the equivalent to the PKCS#1 encoding used before 1.9.3 pem = "-----BEGIN RSA PUBLIC KEY-----\n#{base64}-----END RSA PUBLIC KEY-----"