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.


GOST is a keyed, symmetric block cipher, published in 1990 by the government of the USSR. The block size is 8 bytes, and the key must be 32 bytes. It's S-Boxes may be secret, but this implementation uses published S-Boxes. It is a Feistel network of 32 rounds.

In practise, no effective attacks against GOST have been found. It is secure and fast, and freely available for use.

This implementation was adapted from Wei Dai's C++ code from the Crypto++ project.

require 'crypt/gost'
# a key shorter than 32 bytes will be padded out with zeroes
gost = Crypt::Gost.new("This is a contrived 32 byte key!")
plainBlock = "ABCD1234"
encryptedBlock = gost.encrypt_block(plainBlock)
decryptedBlock = gost.decrypt_block(encryptedBlock)

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