6 Ways to Encrypt Password in PHP
PHP allows to encrypt the password by easy functions. Here is the six ways to encrypt the passwords.
Hash_hmac
hash_hmac — Generate a keyed hash value using the HMAC method
1 2 3 |
<?php
echo hash_hmac('ripemd160', 'Stay foolish, stay hungry.', 'secret');
?>
|
OUTPUT:
d96e9683178a9d6defedde594f7e1944cf8864b6
hash
hash — Generate a hash value (message digest)
1 2 3 |
<?php
echo hash('ripemd160', 'Stay foolish, stay hungry.');
?>
|
OUTPUT:
2f86cf7076249485b549ffc137ab644cb9c9e67a
sha1
sha1 — Calculate the sha1 hash of a string
1 2 3 |
<?php
echo sha1('tobbynews');
?>
|
OUTPUT:
bbb6cc2fc4f0d1cc7d230032d8bca24adc73837c
md5
md5 — Calculate the md5 hash of a string
1 2 3 |
<?php
echo md5('tobbynews');
?>
|
OUTPUT:
6288a589247f3ab3231fc9a86e624ac8
crc32
crc32 — Calculates the crc32 polynomial of a string
Generates the cyclic redundancy checksum polynomial of 32-bit lengths of the str. This is usually used to validate the integrity of data being transmitted.
1 2 3 |
<?php
echo crc32('Stay foolish, stay hungry.');
?>
|
OUTPUT:
1875988720
crypt
1 2 3 |
<?php
echo crypt('Stay foolish, stay hungry.');
?>
|
OUTPUT:
$1$hT2.WM..$yg8axgz8RQxQOdLqZYFpB1




