From: Brian Candler Date: 2008-10-18T00:31:55+09:00 Subject: Re: RSA public_encrypt bug? Brian Candler wrote: > I think I was using integers, so perhaps f.gets.to_i ? > > Also, you could try writing out a PEM, and then using that at the > openssl command line, to check that your key is actually valid. Here's the rest of the code which I used (in 2004 :-) to do this for a private key - however I think if you just remove the p and q bits then you should get a public key instead. require 'openssl' require 'rsa_new' # Input: a large number n # an exponent # factor p of n # factor q of n (n = p * q) # Output: a PEM-encoded private key n = gets.to_i e = gets.to_i p = gets.to_i q = gets.to_i p,q = q,p if p < q puts OpenSSL::PKey::RSA.new_from_parameters(n, e, nil, p, q) -- Posted via http://www.ruby-forum.com/.