|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79555 crypt function gives same output with different inputs that are similar
Submitted: 2020-05-02 01:48 UTC Modified: 2020-05-02 01:53 UTC
From: subless at yahoo dot com Assigned:
Status: Not a bug Package: hash related
PHP Version: 7.3.17 OS: macOS Sierra
Private report: No CVE-ID: None
 [2020-05-02 01:48 UTC] subless at yahoo dot com

The link above is some example code where the string input is slightly different and they all have the same salt, but the output is the exact same each time. Some input-character modifications will change the output which is intended but it's broken so far.

Test script:
echo crypt("passwordpasswoRd", "SALT");
echo "\n";
echo crypt("passwordpassWorD", "SALT");
echo "\n";
echo crypt("passwordPassworD", "SALT");
echo "\n";
echo crypt("passwordpaSSworD", "SALT");
echo "\n";
echo crypt("passwordpassworD", "SALT");

Expected result:
Since the input string is slightly different, I expect to see different output results not identical.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-05-02 01:53 UTC]
-Status: Open +Status: Not a bug
 [2020-05-02 01:53 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

> The standard DES-based crypt() returns the salt as the first two characters of
> the output. It also only uses the first eight characters of str, so longer
> strings that start with the same eight characters will generate the same result
> (when the same salt is used).

If you're trying to hash passwords, use PHP's password hashing functions.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Dec 04 08:03:38 2021 UTC