Blowfish hash

Discussion in 'Ruby' started by James Keener, Oct 27, 2010.

  1. James Keener

    James Keener Guest

    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

    --
    Posted via http://www.ruby-forum.com/.
    James Keener, Oct 27, 2010
    #1
    1. Advertising

  2. On Wed, Oct 27, 2010 at 6:50 PM, James Keener <> wrote:
    > 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/
    Luis Parravicini, Oct 28, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Blowfish hash

    , May 25, 2004, in forum: Java
    Replies:
    2
    Views:
    1,323
    Rajesh Tihari
    May 26, 2004
  2. Claus Wanner

    BlowFish decrypting

    Claus Wanner, Nov 3, 2005, in forum: C++
    Replies:
    2
    Views:
    1,139
  3. d-fan

    blowfish decryption

    d-fan, May 23, 2008, in forum: C Programming
    Replies:
    2
    Views:
    1,131
    Flash Gordon
    May 23, 2008
  4. Damon Getsman
    Replies:
    0
    Views:
    407
    Damon Getsman
    Jun 4, 2008
  5. rp
    Replies:
    1
    Views:
    499
    red floyd
    Nov 10, 2011
Loading...

Share This Page