Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Reid Thompson <Reid.Thompson <at> ateb.com>
Subject: Re: [Nitro] Two-way cryptographic method
Newsgroups: gmane.comp.lang.ruby.nitro.general
Date: Thursday 13th September 2007 11:26:14 UTC (over 9 years ago)
On Thu, 2007-09-13 at 11:07 +0300, George Moschovitis wrote:
> Dear devs,
> 
> a slightly off topic question:
> 
> can anyone suggest a two-way cryptographics function with a robust
> ruby implementation? I to do something like this:
> 
> e = XXX.encrypt("original string", "thekey") 
> b = XXX.decrypt(e,  "thekey") # b == "original string"
> 

you may have already found these...

http://crypt.rubyforge.org/index.html


http://ezcrypto.rubyforge.org/

Simple examples
To encrypt:
Generate a key using a password and a salt. Use the keys encrypt method
to encrypt a strings worth of data:

@key=EzCrypto::Key.with_password "password", "system salt"
  @[email protected] "Top secret should not be revealed"
To decrypt:
Same procedure as encrypt. Generate a key using a password and a salt.
Use the keys decrypt method to decrypt a strings worth of data:

@key=EzCrypto::Key.with_password "password", "system salt"
  @key.decrypt @encrypted
One liners:
These simple examples use one line each:

@encrypted=EzCrypto::Key.encrypt_with_password "password", @salt,"Top
secret should not be revealed"

  EzCrypto::Key.decrypt_with_password "password", @salt,@encrypted
 
CD: 5ms