Reputation: 1372
When I pass this line echo -n aWord | md5
directly in shell I get the expected result - same as PHP md5('aWord')
- but when I call the code from a file I get a different string.
Please help.
Upvotes: 1
Views: 253
Reputation: 31
I can't comment but I do get the same result from a file than from the command line :
$ echo -n 'aWord' | md5sum
a72ef25b2fa8080e6e0643c967284842 -
$ echo -n 'aWord' > file
$ md5sum file
a72ef25b2fa8080e6e0643c967284842 file
Upvotes: 1
Reputation:
If you get following md5s:
=$ echo -n aWord | md5sum
a72ef25b2fa8080e6e0643c967284842 -
And from file:
=$ cat test.file
aWord
=$ md5sum test.file
1d03663ed556e850007c886ce5ad3ade test.file
This is because there is additional character in file - new line character:
=$ hexdump -C test.file
00000000 61 57 6f 72 64 0a |aWord.|
00000006
Upvotes: 2