think tank forum

technology » why the difference?

lucas's avatar
15 years ago
link
lucas
i ❤ demo
euterpe% sha1 -s "abc"
SHA1 ("abc") = a9993e364706816aba3e25717850c26c9cd0d89d
euterpe% echo "abc" | sha1
03cfd743661f07975fa2f1220c5194cbaff48451
euterpe%
Carpetsmoker's avatar
15 years ago
link
Carpetsmoker
Martin
echo adds newline at the end.

% echo "abc" | wc -c
4

Use the -n switch to disable this, see echo(1).

% echo -n "abc" | sha1
a9993e364706816aba3e25717850c26c9cd0d89d
DaGr8Gatzby's avatar
15 years ago
link
DaGr8Gatzby
Drunk by Myself
Pure Genius.
lucas's avatar
15 years ago
link
lucas
i ❤ demo
i assumed it was a newline thing. thanks for the -n switch tip!

i was also trying using stdin, but you have to press return and ^D, which always feeds sha1 a newline. :(

but `echo -n "string" | sha1` should work great.