Blowfish hash

J

James Keener

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
 
L

Luis Parravicini

With the PHP Crypt function
[http://php.net/manual/en/function.crypt.php] I can use blowfish to
create a hash. =A0Is there an equivalent function for ruby? =A0Preferably
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

Have you seen http://philtoland.com/post/807114394/simple-blowfish-encrypti=
on-with-ruby
or this http://crypt.rubyforge.org/blowfish.html ?



--=20
Luis Parravicini
http://ktulu.com.ar/blog/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top