Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A Ruby implementation of the Data Encryption Standard.
branch: master

readme edit

latest commit 6344329426
Robert Sosinski authored
Failed to load latest commit information.
lib cleaned up a few things
test cleanup
.gitignore ignoring vim swap files
MIT-LICENSE adding license
README.markdown readme edit
Rakefile setting default rake task



RubyDES is a full Ruby implementation of the Data Encryption Standard. The purpose of this project was to allow Ruby programmers interested in cryptography a glimpse of how a robust cryptographic algorithm functions in a language they understand.

The best way to understand the RubyDES source code is by following along with a FIPS 46, which you can find at

NOTE: DES is deprecated, and as such, you should not use this implementation in any project you are developing. I highly recommend the AES, TwoFish or Serpent algorithms through the OpenSSL library instead.

Running RubyDES

Using RubyDES is pretty easy. First, construct a new data and key block.

data ='mysecret')
key  ='hushhush')

Then, build a new RubyDES::Ctx object and supply the data and key block.

des =, key)

Finally, let it go.

encrypted_data = des.encrypt

You will then be returned a DES encrypted block that is completely secure against eavesdropping (if it were still 1997).

To decrypt an encrypted data block, just build a new RubyDES::Ctx object in similar fashion as before.

un_des =, key)

And run the DES with the key schedule reversed.

decrypted_data = un_des.decrypt

You can then check to see if it all worked.




If you have any questions, comments or just want to talk shop about crypto, feel free to reach me through my website at

Something went wrong with that request. Please try again.