Will PHP's sha1() and MySQL's SHA() give the same result?

Yes. The sha1 algorithm always produces the same value for the same input; that's the whole point of a hashing algorithm. They also both return a 40-character lowercase hex dump by default.


Both claim to implement RFC 3174. Thus, they produce the same result (otherwise there is a bug in the implementation).


Of course.

Note that the algorithm defines 160 bits and the script language implementations can return their hexadecimal representation as a string instead. The register and the dashes of the hexadecimal representation may be different in some implementations.

However, MySQL and PHP both return in lower case and no dashes.

Tags:

Mysql

Php