crypt() function in php
Last Updated by Pooja Chikara
0 2353
PHP crypt() function is used to get a hashed string corresponding to the string. It is an inbuilt function of PHP.
This function uses different crypt ion algorithms on the basis of the user's machine and accordingly produces different results. This function uses only a one-way cryption algorithm. The return type of this function is string means it returns an encoded string.
Syntax:
crypt($strng, $salt);
here,
- $string is a PHP string that converts into a hashed string by this function. It is mandatory.
- $salt is also a PHP string that is used to generate strong passwords and it works as the base of hashing. Although it is optional for better security it should be declared.
Example:
<?php $input_string="codingtag"; $salt="ASPQ1274vgh@!"; $hashed_string=crypt($input_string,$salt); echo "Hashed string is : $hashed_string"; ?>
Output:

Share:
Recommended Topics:
You May Also Like
PHP Examples
News letter
Subscribe To Never Miss an Article From
Comments
Waiting for your comments