IDEA
Crypt  :: pure-ruby cryptographic cyphers

The Crypt library is a pure-ruby implementation of a number of popular encryption algorithms. Block cyphers currently available include Blowfish, GOST, IDEA, and Rijndael (AES). Cypher Block Chaining (CBC) has been implemented.

Crypt is written entirely in ruby so deployment is simple - no platform concerns, no library dependencies, nothing to compile.

IDEA

IDEA is a keyed, symmetric block cipher, designed by Xuejia Lai and James Massey of ETH-Zürich and published in 1991. The block size is 8 bytes, and the key is 16 bytes. The algorithm has 8 rounds plus a final transformation.

In practise, IDEA is very secure. In theory, there is an attack involving weak keys so this implementation takes an MD5 hash of the key provided by the user and uses that as the algorithm's key. This has the side effect of allowing greater flexibility in the choice of key by the user, since any length of key will be reduced to a 16-byte MD5 hash. IDEA is no longer patented so it is free to use.

This implementation was based on the reference C implementation once published by MediaCrypt.

require 'crypt/idea'
idea = Crypt::IDEA.new("A key up to 56 bytes long")
plainBlock = "ABCD1234"
encryptedBlock = idea.encrypt_block(plainBlock)
decryptedBlock = idea.decrypt_block(encryptedBlock)

To encrypt files, see the section on Cypher Block Chaining.