Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Exchanging md5s between Perl and C

by jettero (Monsignor)
on Oct 28, 2010 at 18:58 UTC ( #868119=note: print w/replies, xml ) Need Help??

in reply to Exchanging md5s between Perl and C

It seems to me it's your line endings...

echo -n "a" | md5sum gives me the same thing as md5_hex("a"). "a\n" and "a" should not hash to the same thing.

  • "a" should be: 0cc175b9c0f1b6a831c399e269772661
  • "a\x0a" should be: 60b725f10c9c85c70d97880dfe8191b3
  • "a\x0d\x0a" should be: 0c629e1d3acda389c88a213374ec62fc

It's also worth noting that Digest::MD5 really is C, as much as /usr/bin/md5sum is: MD5.xs.

Replies are listed 'Best First'.
Re^2: Exchanging md5s between Perl and C
by bart (Canon) on Oct 28, 2010 at 19:14 UTC
    I'm pretty sure that is indeed the cause. Here's a test using md5sum from Perl:
    open OUT, '>', 'tempfile'; print OUT 'a'; close OUT; system('md5sum', '-b', 'tempfile');
    0cc175b9c0f1b6a831c399e269772661 *tempfile
    So yeah, md5sum and Digest::MD5 agree.

    It's the OP's other tests that were flawed.

      ahhk! thank you very much, yes that was it.

      I previously had an issue with 32/64 bit and after going round and round until fixed, somewhere along the line I stared chasing my tail overlooking that minor but oh so important detail.

      cheers for you time! Glad it was as simple as that

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://868119]
[makita]: sign_types parameter in XML::Compile::WSS ::Signature Does have anybody experience how to use it?
[makita]: Need to sign more elements but all types I put in array are ignored. And is always signed only the body
[Discipulus]: no makita sorry. i see in the synopsis of the module: "WARNING: Only limited real-life experience" might be better compose a SOPW with some code example and data
[Discipulus]: ..or inspect the source code of the module
[makita]: I am doing this:
[makita]: my $sig = $wss->signature( schema => $wsdl, token => $token, sign_types=>'wsa: Action','wsa:To', 'wsu:Timestamp', 'wsa:MessageID',' SOAP-ENV:Body', signer=>DSIG_RSA_S HA1, public_key => $cert,
[Corion]: Oof, I haven't done much with signing SOAP requests. markov is usually somebody good to ask via mail ;)
[makita]: I need to create a SOAP call where are signed more types not only the body
[makita]: I am inspecting it second day :)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2017-03-23 08:41 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (285 votes). Check out past polls.