Bug #79555 [Opn->Nab]: crypt function gives same output with different inputs that are similar

From: Date: Sat, 02 May 2020 01:53:58 +0000
Subject: Bug #79555 [Opn->Nab]: crypt function gives same output with different inputs that are similar
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226877@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79555&edit=1 ID: 79555 Updated by: requinix@php.net Reported by: subless at yahoo dot com Summary: crypt function gives same output with different inputs that are similar -Status: Open +Status: Not a bug Type: Bug Package: hash related Operating System: macOS Sierra PHP Version: 7.3.17 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php > 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. https://www.php.net/manual/en/ref.password.php Previous Comments: ------------------------------------------------------------------------ [2020-05-02 01:48:39] subless at yahoo dot com Description: ------------ https://ideone.com/srWv2p 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: --------------- <?php 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79555&edit=1

« previous php.bugs (#226877) next »