Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjdev/mariadb-udf-php-password-hashing
PHP Password Hashing for MariaDB/MySQL UDF
https://github.com/kjdev/mariadb-udf-php-password-hashing
Last synced: 25 days ago
JSON representation
PHP Password Hashing for MariaDB/MySQL UDF
- Host: GitHub
- URL: https://github.com/kjdev/mariadb-udf-php-password-hashing
- Owner: kjdev
- License: mit
- Created: 2013-09-27T01:25:50.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-09-27T01:26:21.000Z (over 11 years ago)
- Last Synced: 2024-11-18T00:52:35.434Z (about 2 months ago)
- Language: C
- Size: 102 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Password Hashing for MariaDB/MySQL UDF
## Dependencies
[PHP Password Hashing](https://github.com/kjdev/php-password-hashing.git)
## Build
```
% mkdir build && cd build
% cmake -DCMAKE_BUILD_TYPE=Release ..
% make
% make install
```Add MariaDB/MySQL UDF.
```
mariadb> CREATE FUNCTION php_password_hash RETURNS STRING SONAME 'php_password_hashing.so';
mariadb> CREATE FUNCTION php_password_verify RETURNS INTEGER SONAME 'php_password_hashing.so';
```## Function
### php\_password\_hash — Creates a password hash
string **php\_password\_hash** ( string _PASSWORD_ , string _ALGORITHM_ , string
_SALT_ , integer _COST_ )```
mariadb> SELECT php_password_hash('password');
+--------------------------------------------------------------+
| php_password_hash('password') |
+--------------------------------------------------------------+
| $2y$10$k./h1h/YV4dMmSxjQG.bzuZtv4./Ri8P0u/3.UnBM/m39HqSA/LJ6 |
+--------------------------------------------------------------+
```Not Use Algorithm.
Use Salt (grater than 22).
```
mariadb> SELECT php_password_hash('password', NULL, 'abcdefghijklmnopqrstuv');
+---------------------------------------------------------------+
| php_password_hash('password', NULL, 'abcdefghijklmnopqrstuv') |
+---------------------------------------------------------------+
| $2y$10$abcdefghijklmnopqrstuu5Lo0g67CiD3M4RpN1BmBb4Crp5w7dbK |
+---------------------------------------------------------------+
```Use Cost (grater than 4 and less than 31).
```
mariadb> SELECT php_password_hash('password', NULL, NULL, 5);
+--------------------------------------------------------------+
| php_password_hash('password', NULL, NULL, 5) |
+--------------------------------------------------------------+
| $2y$05$xQYIrC9yqg/oW/UoOG/vGe.oH0CvRuQ1OB2X7qc6DKBodnDsALnn. |
+--------------------------------------------------------------+
```### php\_password\_verify — Verifies that a password matches a hash
integer **php\_password\_verify** ( string _PASSWORD_ , string _HASH_ )
```
mariadb> SELECT php_password_verify('password', '$2y$10$k./h1h/YV4dMmSxjQG.bzuZtv4./Ri8P0u/3.UnBM/m39HqSA/LJ6') AS verify;
+--------+
| verify |
+--------+
| 1 |
+--------+
``````
mariadb> SELECT php_password_verify('password', 'test') AS verify;
+--------+
| verify |
+--------+
| 0 |
+--------+
```