Trying to figure out why a command line and a perl script using --> my $email_SHA256 = qx(echo $EMAIL_IN | openssl dgst -sha256); yields different results. I am trying to do this without installing the perl module. As you can see in the script, I've REM'd out various attempts at cleaning the data in case it had some carriage returns or Line Feeds.. Any suggestions besides installing the module would be greatly appreciated.

Using the linux command line I enter this:

echo "foobar" | sha256sum aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f - Script output: 0062d3cf2a06daf1d64c931940348cb51c73b28e6fac0dbae65143303286b16d Input File: "130000000640","joe.smith@aol.com" "130000000640","scoobydoo1@gmail.com" "130000000640","foobar" Script: foreach $EMAIL_LIST (@EMAIL_LIST) { my @split_EMAIL_LIST = split(/,/, $EMAIL_LIST); my $USI = $split_EMAIL_LIST[0]; my $EMAIL_IN = $split_EMAIL_LIST[1]; $EMAIL_LENGTH=length($EMAIL_IN) +; #print "Length: $EMAIL_LENGTH\n"; #print "$USI\n"; #my $email_SHA256 = qx(echo -n $EMAIL_IN | openssl dgst -sha256); print "$EMAIL_IN"; chomp($EMAIL_IN); #$EMAIL_IN =~ s/\r\n//; print "$EMAIL_IN"; if($EMAIL_LENGTH > 5) { #echo -n $EMAIL_IN | shasum -a 256 #my $email_SHA256 = qx(echo -n $EMAIL_IN | openssl dgst -sha256); my $email_SHA256 = qx(echo $EMAIL_IN | openssl dgst -sha256); #my $email_SHA256 = exec(`echo -n $EMAIL_IN | sha256sum`); #my $email_SHA256 = exec(echo -n $EMAIL_IN | shasum -a 256); #my $email_SHA256 = exec(printf %s "$EMAIL_IN" | sha256sum); #my $email_SHA256 = qx(printf %s "$EMAIL_IN" | sha256sum); # echo -n "foobar" | openssl dgst -sha256 #my $email_SHA256 = system("sha256sum $EMAIL_IN"); #$email_SHA256 =~ s/stdin//; $email_SHA256 =~ s/\s+\-//; $USI =~ s/"//g; #print "$email_SHA256\n"; my $NEWLINE = $USI . "," . $email_SHA256; #print $NEWLINE; push(@EMAIL_OUT, $NEWLINE); } else { my $NEWLINE = $USI . "," . "No Email Supplied for this USI\n"; print "Length: $EMAIL_LENGTH\n"; print $NEWLINE; push(@EMAIL_NOTVALID, $NEWLINE); } }

In reply to Perl SHA256 by BOK_NEPA

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.