mysql-sha256 implements the SHA256 hash as a MySQL User Defined Function.
mysql-sha256 is free for all purposes without any express guarantee that it works.

Why is it needed?

MySQL includes the MD5() and SHA1() hashes, but both are considered to have been broken. SHA256 is part of the SHA2 family (with SHA224, SHA384 and SHA512) and as far as I know it has not been broken yet.

How does it work?

User Defined Functions are shared object files that MySQL loads when instructed and on each following startup until the function is removed.


Gentoo users: Install dev-db/mysql-sha256-3.1.ebuild in my overlay 'stuge' after adding it via app-portage/layman.

Everyone else: Download mysql-sha256-3.1.tar.bz2 and run make to compile Install by copying into any directory that is searched by the system's dynamic linker. /usr/lib is a safe choice and what my ebuild uses, but /usr/local/lib may be more appropriate on your system.

After installing in a library directory, run the following in the mysql client as a SUPER user (e.g. root):

mysql> create function sha256 returns string soname '';
Query OK, 0 rows affected (0.00 sec)



mysql> select sha256('test');
| sha256('test')                                                   |
| 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 | 
1 row in set (0.00 sec)



Questions or comments? Send me email. My address is peter (at-sign) stuge (period) se.