Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: OpenSSL and Crypt::CBC don't give the same ciphertext

by syphilis (Archbishop)
on Feb 06, 2016 at 02:24 UTC ( [id://1154541]=note: print w/replies, xml ) Need Help??


in reply to OpenSSL and Crypt::CBC don't give the same ciphertext

UPDATE: I fixed it .... It should have been H* instead of h* in my pack statements

On my Windows machine I find that it does indeed need to be "H*".
I also need to binmode $pipe if I want test.bin and cryptx.bin to agree.
The contents of those 2 files will change (but still be in agreement) depending upon whether I binmode $infile.
The binmode $infile therefore apparently affects what is fed in - but, as you observed, both ciphers will receive identical inputs in any case.

I think (untested) you might be able to avoid the binmode calls if you're not on Windows.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: OpenSSL and Crypt::CBC don't give the same ciphertext (binmode always)
by Anonymous Monk on Feb 06, 2016 at 04:10 UTC

    syphilis : I think (untested) you might be able to avoid the binmode calls if you're not on Windows.

    :D how many thousands of times have you seen the solution to a problem was a missing call to binmode?

    binmode on linux, binmode on windows, binmode always :D

      how many thousands of times have you seen the solution to a problem was a missing call to binmode?

      I've seen that lots of times .... on Windows ;-)

      Cheers,
      Rob
        The binmode can't hurt, and makes the code more portable. It makes explicit that this is binary data we are dealing with and we don't want anybody monkeying with our bytes. I do run Perl on Windows machines pretty often, and I have no expectation that whomever I send a script to will be running *nix. If I remember to do this beforehand, I don't have to beat my head against it later wondering why it doesn't work. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1154541]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-18 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found