CBC/BLOWFISH, NEWBIE HELP - CAN'T DECRYPT FROM SAVED FILE

Discussion in 'Perl Misc' started by Homer J., Nov 10, 2004.

  1. Homer J.

    Homer J. Guest

    Hello,

    I'm wondering if the experienced PERL people can help me here.

    I'm stuck. I'm trying to use Crypt::CBC using Blowfish to encrypt
    some data. I can get it to encrypt and decrypt OK as long as I assign
    the ciphertext to a variable and decrpyt it from that variable all
    within the same script execution. However, when I save the ciphertext
    to a text file and then subsequently open the file and read in the
    ciphertext to a variable and finally try to decrypt the cipheredtext I
    get garbage instead of my original test message.

    Someone please help! I'm sure it's, something obviously wrong that
    I've done, but I can't seem to figure out what it is.

    Homer
    Homer J., Nov 10, 2004
    #1
    1. Advertising

  2. Homer J.

    Greg Schmidt Guest

    On 10 Nov 2004 12:39:49 -0800, Homer J. wrote:

    > I'm stuck. I'm trying to use Crypt::CBC using Blowfish to encrypt
    > some data. I can get it to encrypt and decrypt OK as long as I assign
    > the ciphertext to a variable and decrpyt it from that variable all
    > within the same script execution. However, when I save the ciphertext
    > to a text file and then subsequently open the file and read in the
    > ciphertext to a variable and finally try to decrypt the cipheredtext I
    > get garbage instead of my original test message.
    >
    > Someone please help! I'm sure it's, something obviously wrong that
    > I've done, but I can't seem to figure out what it is.


    Are you writing and reading the file in binary mode? Text mode may do odd
    things to binary data such as cipertext.

    --
    Greg Schmidt
    Trawna Publications http://www.trawna.com/
    Greg Schmidt, Nov 10, 2004
    #2
    1. Advertising

  3. Homer J.

    Homer J. Guest

    Greg Schmidt <> wrote in message news:<3g4d2q9c1ghp$>...
    > On 10 Nov 2004 12:39:49 -0800, Homer J. wrote:
    >
    > > I'm stuck. I'm trying to use Crypt::CBC using Blowfish to encrypt
    > > some data. I can get it to encrypt and decrypt OK as long as I assign
    > > the ciphertext to a variable and decrpyt it from that variable all
    > > within the same script execution. However, when I save the ciphertext
    > > to a text file and then subsequently open the file and read in the
    > > ciphertext to a variable and finally try to decrypt the cipheredtext I
    > > get garbage instead of my original test message.
    > >
    > > Someone please help! I'm sure it's, something obviously wrong that
    > > I've done, but I can't seem to figure out what it is.

    >
    > Are you writing and reading the file in binary mode? Text mode may do odd
    > things to binary data such as cipertext.


    Hi Thanks for your replies. Yes I think that did it! Thank you.

    Homer
    Homer J., Nov 14, 2004
    #3
  4. Homer J.

    Homer J. Guest

    Bob Walton <> wrote in message news:<4192c665_3@127.0.0.1>...
    > Homer J. wrote:
    >
    > ...
    > > I'm stuck. I'm trying to use Crypt::CBC using Blowfish to encrypt
    > > some data. I can get it to encrypt and decrypt OK as long as I assign
    > > the ciphertext to a variable and decrpyt it from that variable all
    > > within the same script execution. However, when I save the ciphertext
    > > to a text file and then subsequently open the file and read in the
    > > ciphertext to a variable and finally try to decrypt the cipheredtext I
    > > get garbage instead of my original test message.

    >
    > perldoc -f binmode
    >
    > ...
    > > Homer

    > ...


    Yes I think this did it. Binmode, seems to do the trick. Thanks all for your help.

    Homer
    Homer J., Nov 14, 2004
    #4
    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. jimgardener

    incorrect decryption using AES/CBC

    jimgardener, Jun 19, 2008, in forum: Java
    Replies:
    2
    Views:
    876
    Roedy Green
    Jun 20, 2008
  2. Replies:
    1
    Views:
    431
    Daniel Martin
    Jun 16, 2007
  3. Unreal
    Replies:
    4
    Views:
    131
    Unreal
    Sep 11, 2004
  4. Hal Vaughan
    Replies:
    6
    Views:
    1,058
    Hal Vaughan
    Sep 5, 2005
  5. Replies:
    1
    Views:
    178
Loading...

Share This Page