RSA.rb: RSA Encryption for Ruby
- 100% free and unencumbered public domain software.
- Implements the PKCS#1 data conversion primitives (I2OSP and OS2IP).
- Implements the PKCS#1 encryption/decryption primitives (RSAEP and RSADP).
- Implements the PKCS#1 signature primitives (RSASP1 and RSAVP1).
- Implements RSA key pair generation using Ruby's OpenSSL standard library.
- Compatible with Ruby 1.9.1+ and JRuby 1.5.0+.
- Compatible with older Ruby versions with the help of the Backports gem.
Generating a new RSA key pair
key_pair = RSA::KeyPair.generate(128)
Encrypting a plaintext message
ciphertext = key_pair.encrypt("Hello, world!")
Decrypting a ciphertext message
plaintext = key_pair.decrypt(ciphertext)
The recommended installation method is via RubyGems. To install the latest official release of RSA.rb, do:
% [sudo] gem install rsa # Ruby 1.9.1+ % [sudo] gem install backports rsa # Ruby 1.8.x
To get a local working copy of the development repository, do:
% git clone git://github.com/bendiken/rsa.git
Alternatively, you can download the latest development version as a tarball as follows:
% wget http://github.com/bendiken/rsa/tarball/master
Refer to the accompanying CREDITS file.
- Do your best to adhere to the existing coding conventions and idioms.
- Don't use hard tabs, and don't leave trailing whitespace on any line.
- Do document every method you add using YARD annotations. Read the tutorial or just look at the existing code for examples.
- Don't touch the
AUTHORSfiles. If you need to change them, do so on your private branch only.
- Do feel free to add yourself to the
CREDITSfile and the corresponding list in the the
README. Alphabetical order applies.
- Do note that in order for us to merge any non-trivial changes (as a rule of thumb, additions larger than about 15 lines of code), we need an explicit public domain dedication on record from you.