Forum Moderators: coopster
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
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!