It is One-way string hashing.
The crypt() function returns hashed string on the basis of algorithms i.e Standard DES-based hash, Extended DES-based hash,MD5 hashing, Blowfish hashing or algorithm may be different from system to system, as it basically depends on your system.
This function behaves different on different operating systems. PHP checks what algorithms are available and what algorithms to use when it is installed.
Note : This function is not yet binary safe.
Note : As of PHP 5.3.0, PHP contains its own implementation and will use that if the system lacks of support for one or more of the algorithms.
It has some constants on systems where the crypt() function supports multiple hash types, the following constants are set to “0” or “1” depending on whether the given type is available:
Returns the hashed string or a string that is shorter than 13 characters and is guaranteed to differ from the salt on failure.
[table caption=”” width=”100%” colwidth=”15%|85%” colalign=”left|left”]
Version, Description
PHP 5.6.5 , When the failure string “*0” is given as the salt it will return “*1” for consistency with other crypt implementations. Prior to this version i.e PHP 5.6 would incorrectly return a DES hash.
PHP 5.6.0, Raise E_NOTICE security warning if salt is omitted.
PHP 5.5.21, When the failure string “*0” is given as the salt it will return “*1” for consistency with other crypt implementations. Prior to this version i.e PHP 5.5 (and earlier branches) would incorrectly return a DES hash.
PHP 5.3.7, Added $2x$ and $2y$ Blowfish modes to deal with potential high-bit attacks.
PHP 5.3.2, Added SHA-256 and SHA-512 crypt based on Ulrich Drepper’s.
PHP 5.3.2, Fixed Blowfish behaviour on invalid rounds to return “failure” string (“*0” or “*1”) instead of falling back to DES.
PHP 5.3.0, PHP now contains its own implementation for the MD5 crypt / Standard DES/ Extended DES and the Blowfish algorithms and will use that if the system lacks of support for one or more of the algorithms.
[/table]
In below example we will be using different algorithms:
<?php /* These salts are examples only, and should not be used as it is in your code. You should generate a unique/distinct, correctly-formatted salt for each password. */echo "<b>Crypting without salt.</b></br>"; if (CRYPT_STD_DES == 1) { echo 'Standard DES: ' . crypt('tutorialmines') . "</br>\n"; } else { echo "Standard DES not supported here\n</br>"; } // character salt echo "<b>Crypting with Extended DES using salt.</b></br>"; if (CRYPT_EXT_DES == 1) { echo 'Extended DES: ' . crypt('tutorialmines', '_J9..usesaltstringhereforsalt') . "</br>\n"; } else { echo "Extended DES not supported here\n</br>"; } // 12 character salt starting with $1$ echo "<b>Crypting with MD5 using salt and it starts with $1$.</b></br>"; if (CRYPT_MD5 == 1) { echo 'MD5: ' . crypt('tutorialmines', '$1$usesaltstringhereforsalt$') . "</br>\n"; } else { echo "MD5 not supported here\n<br>"; } // Salt starting with $2a$. The two digit cost parameter: 09. 22 characters echo "<b>Crypting with BLOWFISH using salt and it starts with $2a$.</b></br>"; if (CRYPT_BLOWFISH == 1) { echo 'Blowfish: ' . crypt('tutorialmines', '$2a$07$usesaltstringhereforsalt$') . "</br>\n"; } else { echo "Blowfish not supported here\n<br>"; } // 16 character salt starting with $5$. The default number of rounds is 5000. echo "<b>Crypting with SHA-256 using salt and it starts with $5$.</b></br>"; if (CRYPT_SHA256 == 1) { echo 'SHA-256: ' . crypt('tutorialmines', '$5$rounds=5000$usesaltstringhereforsalt$') . "</br>\n"; } else { echo "SHA-256 not supported here\n<br>"; } // 16 character salt starting with $6$. The default number of rounds is 5000. echo "<b>Crypting with SHA-512 using salt and it starts with $6$.</b></br>"; if (CRYPT_SHA512 == 1) { echo 'SHA-512: ' . crypt('tutorialmines', '$6$rounds=5000$usesaltstringhereforsalt$') . "\n"; } else { echo "SHA-512 not supported here\n<br>"; } ?>
Output will be like below(depending on the operating system):
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…