Re: linux sha1sum .vs php sha1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



'Twas brillig, and Per Jessen at 20/03/09 16:06 did gyre and gimble:
bruce wrote:

hi...

doing some testing with linux sha1sum, and php's sha1 function... are
they both supposed to return the same results for the same chunk of
text.

test

file "a.dat" = "1234567890"

linux:
 echo a.dat > sha1sum -t    != php <? sha1("1234567890"); ?>

any thoughts...

Try "echo -n"

While you've got the right approach, the original command has three (yes 3!) different problems!!!

1. echo automatically appends a new line. Using echo -n will prevent this.
2. You have a file, echo a.dat will echo the file *name* a.dat not it's contents. You probably want to use "cat" instead.
3. You care redirecting (>) rather than piping (|).

So waht you really want is:
cat a.dat | sha1sum

(the -t is not needed).


You can also do:
echo -n "1234567890" | sha1sum

Col





--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux