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
1
vote
1 answer

PHP bcrypt Inconsistent Salt

Before we begin: Yes I am aware that I should use PHP's password_hash function when actually storing passwords. This is a question about the internals of PHP's hashing system. So I was messing around with PHP's crypt function the other day, and I…
Kilo
  • 21
  • 1
1
vote
1 answer

PHP 7.0.7 hash_equals not working with crypt() or hash()?

I didnt see much on this even when searching google, google video & this website. Was wondering why this is if I set. Tried to do some tests on this though. Is mostly password_verify that I see though even on videos. wouldnt matter what I use if…
1
vote
0 answers

syscall number for crypt?

I'm trying to call the crypt system call from Ruby. Ruby has a Kernel#syscall method (http://ruby-doc.org/core-2.3.0/Kernel.html#method-i-syscall), but it needs the number of the system call, not the name. I have found many lists of system call…
Matt Parlane
  • 453
  • 2
  • 11
1
vote
1 answer

CMake with crypt(3)

I trying to make a crypt(3) sample with CMake. #define _GNU_SOURCE #include #include #include #include /* To compile: $ gcc check.c -lcrypt -o check */ int main(void) { /* Hashed form of "GNU libc…
Sergey Ponomarev
  • 2,947
  • 1
  • 33
  • 43
1
vote
1 answer

PHP .crypt() results identical for different strings and salts

Because I am using an older version of PHP, I have to use .crypt(). I was testing some password validation, and the server was validating the wrong password as correct. I then decided to go to the most basic test possible, and I still have this…
Luke
  • 2,038
  • 3
  • 22
  • 46
1
vote
1 answer

Store safely a password in MySQL using PHP and checking it afterwards

I've been reading several posts and trying different techniques to store a password in MySQL. I've decided to use crypt and salt and I've been finally able to insert it on my database. The code used is the following: $cost = 10; $salt =…
Alvaro
  • 1,430
  • 2
  • 23
  • 41
1
vote
1 answer

How should openwall.com's crypt_gensalt() be used?

The signature is: char* crypt_gensalt(const char *prefix, unsigned long count, const char *input, int size) This call: char data[50] = "111111"; crypt_gensalt("$2a$10$", 10, data, sizeof(data)) generates: $2a$10$KRCvKRCv.............. What…
John Cashew
  • 1,078
  • 2
  • 12
  • 28
1
vote
1 answer

Reversing rand in perl 5.10.0, anyone know where to find the source code for rand/srand?

I am doing an assignment where I have a passwd file and I am to find all the passwords in it. Most of them were easy with Jack the ripper and some tweaking but the extra credit requires I find a 8 byte Alphanumeric password generated by rand in perl…
Reni
  • 63
  • 2
1
vote
0 answers

Is Crypt32.lib FIPS 140-2 compliant?

We are using the api CryptProtectData and CryptUnprotectData from the Crypt32.lib for encryption and decryption in our C++ application. Is this lib and the Api FIPS 140-2 compliant?
230490
  • 516
  • 4
  • 15
1
vote
0 answers

How to hash a password in php, save it to the mysqli DB and then compare it to an input later

I just want some simple code on how to hash a password(i read about the function crypt()???) because apparently md5 and sha isn't good enough... and then also how to add salts? my main worry is how i will compare them afterwards with the salt…
1
vote
2 answers

crypt on suse leads to segfault

I'm doing a PAM-type thing, and it needs to check a user's password in /etc/shadow. Usually, this involves reading the password line for the encryption ID, the salt, and the password. Using the ID and salt, the user-provided password can be hashed…
PaulaG
  • 336
  • 1
  • 8
1
vote
1 answer

comparing crypt passwords doesn't seem to work

I am having issues comparing passwords using crypt, one password from post the other pulled from my database... Here is my login code with an example salt: $username = $_POST['username']; $password = $_POST['password']; $cryptSalt =…
FileParts
  • 71
  • 6
1
vote
0 answers

TrueCrypt: Whole container broken on single bit error?

I wondered what would happen to a TrueCrypt (pre-NSA, i.e. v7.1a) container, if just a single random bit of it gets flipped? Does this cause the whole container to become corrupted? Is there a way to fix the container (without knowing which bit…
1
vote
0 answers

Low Level IO with Crypt

I am trying to compare a encrypted string that is taken from each line of a file to AAAA-ZZZZ until it finds its match of the password. I am guaranteed that the user password is of 4 characters. What I am trying to do is take in the file using…
kids love
  • 61
  • 2
1
vote
4 answers

PHP and C# MD5 crypt does not give the same output?

This is the encryption I have when people register on my site: $salt = generateSalt(); $hashedPassword = crypt($userPass, $salt); and here is my generateSalt function: function generateSalt() { $salt = uniqid(mt_rand(), true); $salt = '$1$'…