RSA.rb: RSA Encryption for Ruby

RSA.rb is a [Ruby][] library that implements the [RSA][] encryption algorithm and the [PKCS#1][] cryptography standard.

Features


  • 100% free and unencumbered [public domain](unlicense.org/) 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.

Examples


require 'rsa'

### 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)

Documentation


<rsa.rubyforge.org/>

Dependencies


  • [Ruby](ruby-lang.org/) (>= 1.9.1) or (>= 1.8.1 with [Backports][])

Installation


The recommended installation method is via [RubyGems](rubygems.org/). 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

Download


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

Author


Contributors


Refer to the accompanying CREDITS file.

Contributing


  • 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][YARD-GS

    or just look at the existing code for examples.

  • Don’t touch the ‘.gemspec`, `VERSION` or `AUTHORS` files. If you need to change them, do so on your private branch only.

  • Do feel free to add yourself to the ‘CREDITS` file 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.

License


This is free and unencumbered public domain software. For more information, see <unlicense.org/> or the accompanying UNLICENSE file.

[Ruby]: ruby-lang.org/ [RSA]: en.wikipedia.org/wiki/RSA [PKCS#1]: en.wikipedia.org/wiki/PKCS1 [YARD]: yardoc.org/ [YARD-GS]: rubydoc.info/docs/yard/file/docs/GettingStarted.md [PDD]: unlicense.org/#unlicensing-contributions [Backports]: rubygems.org/gems/backports