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
2
votes
1 answer

Crypt is different on server than on local machine

I am developing an API using PHP (Codeigniter) and Phils RESTserver. I am creating a hash using crypt() with the password and the salt. The problem is that the hash that is the result of the crypt() algorithm is different on my local machine and on…
Jonathan Clark
  • 19,726
  • 29
  • 111
  • 175
2
votes
1 answer

Go RSA decrypt using public key implementation from java

Provider has this sample JAVA code to decrypt RSA using public key. public static byte[] decryptByPublicKey(byte[] encryptedData, String publicKey) throws Exception { byte[] keyBytes = Base64.decodeBase64(publicKey); …
Kevin Kaburu
  • 504
  • 4
  • 19
2
votes
1 answer

crypt.crypt raises an OSError: Invalid Argument

I use an up to date Debian 10. I have unexpected behavior with python crypt.crypt, some calls raise an OSError: Invalid Argument exception, without further explanation, so I am not really sure what is happening. >>> # debian - python3.9 >>> import…
azmeuk
  • 4,026
  • 3
  • 37
  • 64
2
votes
1 answer

Verifying hashed password vs user input with crypt builtin

I am trying to find out how to use Crypt function to verify stored hashed password with user's entered data. I use below code to generate password's digest using randomly generated salt. In next step, I use previously generated digest to be used as…
shahesam84
  • 33
  • 6
2
votes
3 answers

Upgrading PHP (<5.3.2) passwords generated using invalid CRYPT_STD_DES salt

Long story short, I've got some passwords that were improperly salted and hashed in a version of PHP that allowed the crypt() function to fall back to the CRYPT_STD_DES algorithm if the salt was invalid. However in PHP 5.3.2+: 5.3.2 Fixed Blowfish…
That Guy
  • 29
  • 7
2
votes
3 answers

C's Crypt() like function in Java

I have been reading some codes regarding encrypting a password in Java. Which seems a bit more computing intensive. Is there a quick way to encrypt a string similar to C or Ruby? For example, in Ruby: 'hello'.crypt('$6$salt') # =>…
15 Volts
  • 1,946
  • 15
  • 37
2
votes
2 answers

Oracle: Is there a way to encode a value using the unix crypt method?

Is there a way to encode a value using the unix crypt method in oracle 10g? (Other DBMS like MySQL support this)
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
2
votes
1 answer

laravel difference between crypt::encrypt and crypt::encryptString

I am still new on laravel, and just use laravel package name Crypt but I found some that there are Crypt::encrypt and Crypt::encryptString what is the difference between them?
Steven Y.
  • 41
  • 1
  • 6
2
votes
1 answer

Is there a perl module to validate passwords stored in "{crypt}hashedpassword" "{ssha}hashedpassword" "{md5}hashedpassword"

I have a table which stores user login infomration, which contains passwords in the below scheme: {crypt}hashedpassword {ssha}hashedpasswordsalted {md5}hashedpassword ..... Is there a Perl module that understands this scheme and is able to…
Syborg78
  • 21
  • 1
2
votes
1 answer

How to get Perl crypt to encrypt more than 8 characters?

Only the first 8 characters is encrypted when the Perl crypt function is used. Is there a way to get it to use more characters? As an example: $crypted_password = crypt ("PassWord", "SALT"); and $crypted_password = crypt ("PassWord123",…
gpwr
  • 988
  • 1
  • 10
  • 21
2
votes
1 answer

Use pgcrypto to verify passwords generated by password_hash

I have password hashes stored in a Postgresql database generated with: password_hash($password, PASSWORD_DEFAULT); Now I would like to also be able to verify a user password with Postgresql and pgcrypto. But pgcrypto's crypt() function is not able…
madflow
  • 7,718
  • 3
  • 39
  • 54
2
votes
1 answer

postgresql – No crypt function on Debian stretch

I have PostgreSQL 9.6 installation on my Debian Stretch (9). When I want to use crypt() or gen_salt() functions, it says: ERROR: function gen_salt(unknown, integer) does not exist LINE 1: select gen_salt('bf', 8) ^ HINT: No function…
jiwopene
  • 3,077
  • 17
  • 30
2
votes
1 answer

Why using crypt in glibc cause compiler warning?

I tried to compiler the following code(minimum example, see the edit for the whole code): // a.c #include #define _XOPEN_SOURCE #include int main(int argc, char* argv[]) { puts((const char*) crypt("AAAA", "$6$2222")); …
JiaHao Xu
  • 2,452
  • 16
  • 31
2
votes
1 answer

Python crypt.crypt not using sha512 despite $6$

For some reason using the crypt module uses the 13 char hash rather than sha-512 no matter what I try. I have seen countless questions about problems, but none of them match mine. Is there simply no way to change the crypt method? >>> import…
UnsignedByte
  • 849
  • 10
  • 29
2
votes
1 answer

What type of encryption is used in MySQL ENCODE?

MySQL ENCODE('pass','salt') What kind of cryptography is used? Very similar to DES Is it brute force to go salt when the password is known?