|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11240 Crypt works only with the first 8 chars
Submitted: 2001-06-01 10:21 UTC Modified: 2001-06-01 11:44 UTC
From: greg at jalix dot org Assigned:
Status: Closed Package: *Encryption and hash functions
PHP Version: 4.0.5 OS: Linux 2.2.19
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: greg at jalix dot org
New email:
PHP Version: OS:


 [2001-06-01 10:21 UTC] greg at jalix dot org
The crypt function only crypt the first 8 chars of the string.
I have tested it only with the Standard DES encryption with a 2-char salt.

For example :
  crypt('mypasswd', 'Xz')
  crypt('mypasswdblah', 'Xz')
will produce the same string

This is not specified in the doc, and this is not the normal behaviour
of the Linux crypt function...
But unfortunately, if you correct this, some old crypted string will
not match with the new (and correct) encryption.

So, do you know this bug, and what are you planing ?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-01 11:44 UTC]
This is exactly the normal behaviour of Linux crypt()
if you pass it a 2 char salt.

Try with MD5. That will work on longer strings than 8 chars.


crypt/DES is 56 (7 ASCII bits * 8) bits based..

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Dec 05 08:05:54 2022 UTC