ID: 26485 Updated by: [EMAIL PROTECTED] Reported By: dietrich at pegestorf dot de -Status: Assigned +Status: Bogus Bug Type: *General Issues Operating System: linux PHP Version: 4.3.4 Assigned To: derick New Comment:
There is no bug here at all. The echo test you do is flawed because echo always appends a \n, see with: echo -n test | openssl dgst -sha1 a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 that that is correct. Your file also has 5 characters most likely (using VIM?). With really only 'test' in it it works fine: [EMAIL PROTECTED]:~$ ls -l /tmp/data -rw-r--r-- 1 derick derick 4 Dec 1 13:53 /tmp/data [EMAIL PROTECTED]:~$ php-4.3dev -r 'echo sha1_file("/tmp/data");'; a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 and [EMAIL PROTECTED]:~$ openssl dgst -sha1 /tmp/data SHA1(/tmp/data)= a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 Previous Comments: ------------------------------------------------------------------------ [2003-12-01 07:50:09] [EMAIL PROTECTED] I'll have a look at fixing this... ------------------------------------------------------------------------ [2003-12-01 07:41:35] dietrich at pegestorf dot de Description: ------------ I try to generate a sha1 hash with sha1() $hash = sha1("test"); $hash is calculated wrong to: "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" I have a file /tmp/data with the word "test" in it (no carriage return at the end) $hash = sha1_file("/tmp/data"); $hash is calculated right to: "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83" let's go tho the command line and enter: echo test | openssl dgst -sha1 this generate also "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83" same than openssl dgst -sha1 /tmp/data If I generate the hash over "test\n" with the sha1() the hash is calculated right to "4e1243bd22c66e76c2ba9eddc1f91394e57f9f83" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26485&edit=1