[Nitro] Two-way cryptographic method

Reid Thompson Reid.Thompson at ateb.com
Thu Sep 13 07:26:14 EDT 2007


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"
  @encrypted=@key.encrypt "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, at encrypted


More information about the Nitro-general mailing list