# Compiled sha256 lib for mysql but it produces other hash tha



## urello (Sep 18, 2014)

My question is not directly FreeBSD related, but i use it as OS for my mail server, so i hope to get some help there.
I need to "teach" mysqlserver to use sha256 algorithm. I downloaded source from http://stuge.se/mysql-sha256/mysql-sha256-3.tar.bz2, compiled and put in /usr/local/lib/mysql/plugin/. Then i created function in mysql

```
mysql> create function sha256 returns string soname 'sha256.so';
```
It went fine but mysqland dovecotproduce different hashes.


```
[root@taz /usr/ports/mail/postgrey]# mysql -u root -p -e "SELECT sha256('test')"
Enter password:
+------------------------------------------------------------------+
| sha256('test')                                                   |
+------------------------------------------------------------------+
| b1499ffe49c3b4f354e30349bca8e62f08604eab6b687322df47d4f8fce76f19 |
+------------------------------------------------------------------+

[root@taz /usr/ports/mail/postgrey]# doveadm pw -s SHA256.hex -p test           {SHA256.HEX}9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08

[root@taz /usr/ports/mail/postgrey]# doveadm pw -s SHA256 -p test
{SHA256}n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=
```
Why hashes are different? MD5 and SHA1 hashes are same, only SHA256 are different.


----------

