From: Brian Candler Date: 2007-08-03T21:46:59+09:00 Subject: Re: public key encrypt I know how to use public key to encrypt data if I create public/private > key pair by myself through OpenSSL::PKey::RSA. However, if I only know > other guy's public key, how could I encrypt data with his/her public > key? Is there any method in the module OpenSSL::PKey::RSA to support it? What's your current code? You should just be able to read in the public key (e.g. from a PEM file), and use that to encrypt. A quick google for "ruby openssl RSA encrypt" turns up a couple of examples: http://blog.leetsoft.com/2006/03/14/simple-encryption http://stuff-things.net/2007/06/ Do either of those do what you want? Basically, if you can do what you want from the command line, using the 'openssl' tool, then it's pretty straightforward to map it to the OpenSSL API, since the tool is just a wrapper around it. B.