Forum Moderators: coopster

Message Too Old, No Replies

PHP sha1 implementation

not standard sha-1 digest implementation in PHP?

         

caste

1:24 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



Hi there,

I've experienced a vary strange problem working with PHP and payment gateways.

If I use the sha1 function for some string I get the encrypted string, but this function output is different from the one I get using openssl on the command line of a linux machine. Ex:

inside a php I write: sha1("12345")
in the command line I type: echo 12345 ¦ openssl sha1

The output of both functions is different.

However, if I store the string 12345 in a somefile.txt and I use sha1_file() function the result is the same as the standard expects, so following the previous example, when I write:

inside a php: sha1_file("somefile.txt")
in the command line I type: echo 12345 ¦ openssl sha1

The output of both functions is the same.

Anybody knows if this behaviour is normal, and if it is what's it obeying to?)

Caste

coopster

9:28 pm on Nov 6, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, caste.

The output of sha1() or sha1_file() will be the same in the event that the text string is exactly the same as the content residing in the file. Are you certain you don't have any whitespace characters such as a newline in your file? That will definitely cause a difference!