Blowfish hash

With the PHP Crypt function
[http://php.net/manual/en/function.crypt.php] I can use blowfish to
create a hash. Is there an equivalent function for ruby? Preferably
native code, as the cost parameter we use is high (more than my example
below) and takes about 3 seconds in native code to run.

Before you reply:

  1. Block ciphers can be used as one-way hash functions and vice-verse
  2. The salt does not need to be formatted the same, just the output of
    hashing itself (excluding the salt)

So, for example:
php> echo crypt(‘this is a test’, ‘$2a$12$abcdefghijklmnopqrstuv’);
$2a$12$abcdefghijklmnopqrstuulXXDmWA0ghEUfxodWoZCvd8NILoFYg2

Where:
‘12’ is the ‘base-2 logarithm of the iteration count for the underlying
Blowfish-based hashing algorithmeter’
‘abcdefghijklmnopqrstuv’ is the IV (I think?) in base64 (I’m not 100%
sure why it only uses to u but fails w/o the v)
‘ulXXDmWA0ghEUfxodWoZCvd8NILoFYg2’ is the output of the hashing
algorithm

php> echo crypt(’//007 my example rocks because it’s amazing!!!’,
‘$2a$12$wellwhatdoyaknowimhere’);
$2a$12$wellwhatdoyaknowimheremd2ausy8yN9LSOrhdYQXUwYi1oQIEzi

Where:
‘12’ is the ‘base-2 logarithm of the iteration count for the underlying
Blowfish-based hashing algorithmeter’
‘wellwhatdoyaknowimhere’ is the IV (I think?) in base64
‘md2ausy8yN9LSOrhdYQXUwYi1oQIEzi’ is the output of the hashing algorithm

Thanks,
Jim

On Wed, Oct 27, 2010 at 6:50 PM, James K. [email protected]
wrote:

algorithm
‘md2ausy8yN9LSOrhdYQXUwYi1oQIEzi’ is the output of the hashing algorithm
Have you seen
http://philtoland.com/post/807114394/simple-blowfish-encryption-with-ruby
or this http://crypt.rubyforge.org/blowfish.html ?