Questions tagged [crypt]

crypt() is Unix C library function used for hashing passwords. It is also found in PHP, Perl, Python and various other languages.

crypt(3) is a Unix C library function used for hashing passwords. The crypt() function takes in a password and an optional salt string (chosen randomly if not supplied), and calculates a cryptographic message digest based on them. The digest includes the salt used to generate it, so that, when the user re-enters their password, the digest can be recalculated and compared with the previously stored value.

Despite its name, the crypt(3) function cannot actually be used to encrypt data; the transformation it implements is deliberately non-reversible, so that its output cannot be decrypted to recover the original password.

The "traditional" hashing algorithm used by the original Unix crypt(3) was based on a modified version of the DES block cipher, and only supported passwords of up to 8 characters, with 7 bits per character, and a two-character salt with 6 bits per character. This algorithm is nowadays considered insecure due to its limited keyspace and high speed, which allow an attacker using modern computers to test all possible passwords by brute force in a relatively short time. Nonetheless, most crypt(3) implementations still include it for the sake of backwards compatibility.

Most modern crypt(3) implementations include various alternative hashing algorithms, which typically support arbitrarily long passphrases, longer salts and adjustable iteration counts to deliberately slow down the digest calculation for key stretching. One well known example of such an algorithm is , which is based on the Blowfish cipher.

Functions similar in name and purpose to (and possibly implemented by) the Unix crypt(3) function are also found in several high-level languages, including PHP, Perl and Python.

The crypt(3) function should not be confused with the Unix command line utility crypt(1), which is an obsolete and insecure file encryption utility. For a modern replacement, see .

553 questions
6
votes
3 answers

How do I replace the cakephp password hashing algorithm?

I have an existing database I'm trying to put a cake app on top of. The old app used crypt() in Perl to hash the passwords. I need to do the same in the PHP app. Where is the correct place to make that change in a standard cakephp app? And what…
danb
  • 10,239
  • 14
  • 60
  • 76
6
votes
3 answers

How to decrypt a password generated in crypt()?

What I am searching for is a decrypt function to the crypt(3) function. Reading the manual they only refer me to see login(1), passwd(1), encrypt(3), getpass(3), passwd(5), but as far as I am aware, non of them can be used to decrypt the string. I…
Salviati
  • 758
  • 2
  • 9
  • 28
6
votes
5 answers

Can you convert the output of php crypt() to valid MD5?

I have some strings that have been encrypted using the PHP function crypt(). The outputs look something like this: $1$Vf/.4.1.$CgCo33ebiHVuFhpwS.kMI0 $1$84..vD4.$Ps1PdaLWRoaiWDKCfjLyV1 $1$or1.RY4.$v3xo04v1yfB7JxDj1sC/J/ While I believe crypt() is…
TheKeys
  • 675
  • 2
  • 7
  • 14
6
votes
1 answer

PHP crypt() returns *0 failure string in version 5.6.4, but not 5.4,

echo crypt('test', "$2a$07$"); produces a long hash in PHP version 5.4.16, but it produces the "failure string" *0 in 5.6.4. Reading the PHP docs on crypt(), I'm still not quite clear why, though the Changelog mentions the *1 being returned instead…
user49438
  • 889
  • 7
  • 20
6
votes
2 answers

How is crypt($pass, '$2y$09$salt') === crypt($pass, crypt($pass, '$2y$09$salt')) in PHP?

I'm ok really confused on the crypt() PHP function. How does the following two crypt functions give the same output when the second crypt is clearly using an different 2nd argument? Diff salt means diff hash right? echo crypt("password",…
user3388884
  • 4,748
  • 9
  • 25
  • 34
6
votes
5 answers

Using the crypt module in Windows?

In IDLE and Python version 3.3.2, I try and call the python module like so: hash2 = crypt(word, salt) I import it at the top of my program like so: from crypt import * The result I get is the following: Traceback (most recent call last): File…
codaamok
  • 717
  • 3
  • 11
  • 21
6
votes
3 answers

how to use crypt( ) method in Linux?

I just want to use crypt() to generate an encrypted password,and I write a demo which invoke the crypt() method. Here is my code #include #include #include int main() { printf("%s\n",crypt("abc","ab")); …
user1198331
  • 139
  • 2
  • 3
  • 10
5
votes
3 answers

How are Crypt and Salt more secure than MD5 against a brute force attack?

I read on PHP.net that MD5 is useless, and they suggest using crypt + salt. So, I went to their function description and read
user1117862
  • 121
  • 3
  • 9
5
votes
1 answer

PHP crypt() with sha256 in Zend Server CE 5.5 truncates the supplied salt

During an upgrade from Zend Server CE 5.1 to Zend Server CE 5.5, PHP also got an upgrade from 5.3.5 to 5.3.8. After this transition the login function for a zend application I'm working on suddenly broke. Trying to debug it, it looks likes the…
Patrick
  • 1,044
  • 1
  • 10
  • 18
5
votes
2 answers

Is the crypt() function declared in unistd.h or crypt.h?

I'm using GCC 4.6.0 (on an otherwise unidentified platform). I am using the crypt() function to encrypt a password. I have never used that function before so I checked out the main page: man 3 crypt And it says to include the unistd.h…
ant2009
  • 27,094
  • 154
  • 411
  • 609
5
votes
2 answers

Python crypt module

I was looking up on python modules, when I found something called 'crypt'. I do not understand. I have tried reading up on this, what is this 'salt' thing, what is the use of this crypt module, and is there some sort of way that I can apply 'crypt'…
python_noobie
  • 47
  • 1
  • 2
  • 5
5
votes
1 answer

Cipher/Encrypt and uncrypt passwords in .properties files using Talend Data Integration

One suggested way to run jobs is to save context parameters in properties files. Like this one: # #Wed Dec 16 18:23:03 CET 2015 MySQL_AdditionalParams=noDatetimeStringSync\=true MySQL_Port=3306 MySQL_Login=root…
5
votes
1 answer

Python SHA512 salted passwords with crypt on MacOS X

I am trying to generate encrypted password strings, similar to /etc/shadow in Linux. For some reason the output I am getting is different. Any ideas what am I missing and is one has longer than the other (not counting the salt…
user1781482
  • 623
  • 3
  • 15
  • 24
5
votes
0 answers

Generate SHA512 with JavaScript like PHP's crypt() Function

I'm trying to duplicate PHP's crypt() function in JavaScript with regards to generating a SHA512 hash, such as this: $hash = crypt( $text, '$6$' . $salt ); This generates something like this: $6$salt$hashedtext I'm trying with CryptoJS, like…
Nick Coons
  • 3,682
  • 1
  • 19
  • 21
5
votes
0 answers

CertFindCertificateInStore fails to load self-signed certificates generated on different machine

I'm trying to load a self-signed certificate generated on a different host and imported to my machine. Cert has been imported and shows up in mmc correctly. But CertFindCertificateInStore fails to load, when searched through SHA1 thumbprint. Here's…
cryptbaker
  • 51
  • 3
1 2
3
36 37