Musings about Coding, Business and other Geek Stuff Live and Direct from somewhere on the planet
July 20, 2005
First release of my EzCrypto library for Ruby

While Ruby comes with an OpenSSL binding, it is not easy to use and it is basically not documented.

Features

  • Defaults to AES 128 CBC
  • Will use the systems OpenSSL library for transparent hardware crypto support
  • Single class object oriented access to most commonly used features
  • Ruby like

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"
  
bc. EzCrypto::Key.decrypt_with_password "password", @salt,@encrypted

Keys

The only class you need to know for most uses og EzCrypto is the Key class. You don’t need understand ciphers or the encryption life cycle.

Generating a random key

The most secure type of key is the randomly generated key:

@key=EzCrypto::Key.generate

Initializing a key with raw key data

If you already have a key from some other source, you simply have to call the constructor with the raw data:

@key=EzCrypto::Key.new @binarykey

Initializing a Key with a Base64 encoded key

As seen above you can create a key from a password. This should be used if you don’t want the key to be stored on disk for example:

@key=EzCrypto::Key.with_password "Secret password"

Initializing a Key with a Base64 encoded key

If you already have a key from some other source in the popular Base64 encoded format, you use the decode class method:

@key=EzCrypto::Key.decode @binarykey

Exporting the key

To export or save a key use the encode method (or to_s) method for a Base64 encoded key or raw as the raw binary data.

puts @key.encode
puts @key.raw
  
The raw method could be used for storing in a database using a tinyblob column.

Encryption and Decryption

EzCrypto is optimized for simple encryption and decryption of strings. There are encrypt/decrypt pairs for normal binary use as well as for Base64 encoded use.

Regular raw use

Assuming you have generated a key using one of the above methods:

@encrypted=@key.encrypt("clear text")
@decrypted=@key.decrypt(@encrypted)
assert "clear text", @decrypted

Base64 encoded use

This uses the encrypt64 and decrypt64 methods. Otherwise it is all the same:

@encrypted=@key.encrypt64("clear text")
@decrypted=@key.decrypt64(@encrypted)
assert "clear text", @decrypted

Where to get it

You can download it from it’s RubyForge project

I have uploaded a gem, but I’m not sure if there is anything else I need to do for it to work, but eventually anyway you should be able to do: gem install ezcrypto.

Also check out the EzCrypto Documentation .

Posted by pelleb at 03:16 PM
July 14, 2005
Selling talk.org

As part of bootstrapping (self funding) my latest project StakeItOut and SoapBX I have put the “Talk.org” domain name for same with a few others.

For more on why I’m doing this and also more on the domains for sale see “Selling talk.org….” on my bootstrapping blog

Posted by pelleb at 06:27 AM
July 12, 2005
iSync 2.1 released with support for Nokia 6630, but doesn't quite work yet

The good news is that Apple just released iSync 2.1 with support for all the missing Symbian phones including my Nokia 6630. I was so thrilled.

Half ways through the syncing process though the agent stops on own accord for some reason on the phone and you get the following message:

Such pain. I don’t know if it might be a memory issue or if I need to update the firmware on my phone. I suspect it’s the firmware. I know there is a new firmware version. I guess I will have it flashed today.

** Update **

Thanks Chris. I got mine working as well using your advice. I am wondering if it could be Danish characters or something. At work I sync my phone with Lotus Notes, maybe there is something in these calendar entries that do the same.

So finally I now also have iSync. Because of this I have never had any reason to use iCal or Address book before.

Posted by pelleb at 02:05 AM