Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Digest::SHA gives different values for unix/windows

by Jim (Curate)
on Jun 12, 2013 at 01:40 UTC ( #1038371=note: print w/ replies, xml ) Need Help??


in reply to Digest::SHA gives different values for unix/windows

#supposed to be portable and os independant? not working.

I suspect it is working just fine.

The default FTP translation mode is ASCII, which does line ending localization (LF to CRLF, CRLF to LF, etc.). You don't want this for binary files such as compressed archives. You want binary mode instead. See File_Transfer_Protocol:  Communication and data transfer for more details.

It's a good thing you're computing message digests on both of sides of the FTP file transfer. Your strategy worked!


Comment on Re: Digest::SHA gives different values for unix/windows
Re^2: Digest::SHA gives different values for unix/windows
by rmahin (Beadle) on Jun 12, 2013 at 06:02 UTC

    Well that would explain why they are different using ftp. However, in the perl scripts I wrote, I explicitly set the the socket to binmode on both client and server side. Is there something else I should be doing in addition to this? This is the part I'm particularly interested in as I only used ftp to see if something in my code was messing it up.

    Thanks for the response!

      Have you used another utility to compute the SHA-256 or MD5 digests of the binary files on both ends of the file transfer? It's not clear to me yet if your problem is that the files are not the same, and so something's wrong with the file transfer, or that the files are the same, and so something's wrong with your digest computation. Unequivocally prove the difference or sameness of the files first, then you'll know with certainty which of two different problems you must solve.

      (I like md5deep for Microsoft Windows.)

        Alright so tested it using sha256deep64.exe for windows, and sha256sum for linux. Saw the same results using the perl script. Would appear the problem is with my file transferring.

Re^2: Digest::SHA gives different values for unix/windows
by rmahin (Beadle) on Jun 12, 2013 at 17:06 UTC
    On another note, tried using binary mode transfer in FTP, and the values were a match. This was using winscp. I still have yet to replicate this in perl. Should setting binmode on the socket, and the file I'm reading in be enough?

      What protocol are you using in your Perl script to transfer the files via the Internet? I presume from what you've written that you're not using Net::FTP.

      Update:  Does this thread help?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-12-20 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls