1// To hash the password, use
2password_hash("MySuperSafePassword!", PASSWORD_DEFAULT)
3
4// To compare hash with plain text, use
5password_verify("MySuperSafePassword!", $hashed_password)
1//hash password
2$pass = password_hash($password, PASSWORD_DEFAULT);
3
4//verify password
5password_verify($password, $hashed_password); // returns true
1
2/* User's password. */
3$password = 'my secret password';
4
5/* Secure password hash. */
6$hash = password_hash($password, PASSWORD_DEFAULT);
7
8
1$password = 'test123';
2
3/*
4 Always use salt for security reasons.
5 I'm using the BCRYPT algorithm use any valid one you like.
6*/
7$options['salt'] = 'usesomesillystringforsalt';
8$options['cost'] = 3;
9echo password_hash($password, PASSWORD_BCRYPT, $options)
1
2<?php
3echo hash('ripemd160', 'The quick brown fox jumped over the lazy dog.');
4?>
5
6
1hash($hashingMethod, $dataToBeHashed, $BinaryOutputMode = false)
2
3some hashingMethod options:
4
5md5
6sha1
7sha256
8sha384
9sha512