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

If salt is not used, will they be the same?

+8
php mysql
source share
3 answers

Yes. The sha1 algorithm always gives the same value for the same input; that the whole point of the hashing algorithm. They also return a default 40 character string hex dump.

+8
source share

Both pretend to implement RFC 3174. Thus, they give the same result (otherwise there is an error in implementation).

+2
source share

Of course.

Note that the algorithm determines bit 160 , and language script implementations can return a hexadecimal representation as a string. The case and dash of the hexadecimal representation may be different in some implementations.

However, MySQL and PHP returned in lowercase and without dashes.

+2
source share

All Articles