Blowfish and Rails

Discussion in 'Ruby' started by rumz, Dec 6, 2007.

  1. rumz

    rumz Guest

    I'm working on encrypting some data using blowfish. My Client uses php
    and blowfish for encryption and i use ror and blowfish
    the php snippet is as follows,

    $key = 'some key';
    $data = 'data to be encrypted'

    $iv = pack('H*', substr($key, 0, 16));

    $literak_key =", $key.$key.$key.substr($key,16),";
    $cipher = mcrypt_module_open(MCRYPT_BLOWFISH, '', 'cbc', '');
    mcrypt_generic_init($cipher, $literalKey, $iv);

    When i try to do the same thing using rails, i get a different
    encrypted key.

    Also, blow fish can take only 56 byte key as its input, so i
    manipulated the key as how its done in php and packed it to a hex.

    however am not sure how i can pass the iv

    blowfish = Crypt::Blowfish.new(key)
    encrypted_string = blowfish.encrypt_block(plain_text)

    any thoughts? thank you.

    Cheers
    Ramya
     
    rumz, Dec 6, 2007
    #1
    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,355
    Rajesh Tihari
    May 26, 2004
  2. Claus Wanner

    BlowFish decrypting

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

    blowfish decryption

    d-fan, May 23, 2008, in forum: C Programming
    Replies:
    2
    Views:
    1,189
    Flash Gordon
    May 23, 2008
  4. Damon Getsman
    Replies:
    0
    Views:
    429
    Damon Getsman
    Jun 4, 2008
  5. Hal Vaughan
    Replies:
    6
    Views:
    1,246
    Hal Vaughan
    Sep 5, 2005
Loading...

Share This Page