BOK_NEPA has asked for the wisdom of the Perl Monks concerning the following question:
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); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl SHA256
by NERDVANA (Priest) on Feb 13, 2023 at 20:40 UTC | |
by Anonymous Monk on Feb 14, 2023 at 02:02 UTC | |
by BOK_NEPA (Initiate) on Feb 14, 2023 at 11:07 UTC | |
by hippo (Archbishop) on Feb 14, 2023 at 13:42 UTC | |
by BOK_NEPA (Initiate) on Feb 15, 2023 at 12:37 UTC | |
| |
by choroba (Cardinal) on Feb 14, 2023 at 22:49 UTC | |
by Anonymous Monk on Feb 15, 2023 at 02:24 UTC | |
|
Re: Perl SHA256
by GrandFather (Saint) on Feb 13, 2023 at 20:24 UTC | |
|