MD5 checksum in PHP and BASH

I wondered why the same word has different MD5 checksum if I use the PHP md5(-) method and BASH md5sum command. What I mean is: <?php echo md5("sol"); ?> The result is: 12313a3d28f802e3a22b07d2e01c6dcf $ echo "sol"|md5sum The result is: 56717d999058f0e053d4b580c9396a92 It’s so because the echo command – by default – adds a newline character after its execution, so it really creates a MD5 checksum of: ‘sol\n’. To avoid it, you can use the -n echo switch which disables the trailing newline character for this command....

January 15, 2011 · 1 min