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 blowfish cbc VS Perl Crypt

I'm encrypting client numbers in PHP using openssl_encrypt. $value = '01715034842'; $key = 'pi3kn3W@k@cj3'; $iv = 'Toy@dtv!'; $cipher = 'bf-cbc'; $crypted = openssl_encrypt($value, $cipher, $key, true, $iv); $hashValue =…
1
vote
1 answer

How do I get to the same results as the Linux crypt and salt output?

I used the following command on my Ubuntu machine "openssl passwd -crypt - salt pass book" to generate a salted password. What hash is the output made up of? e.g SHA-512, MD5 etc. Also, i'm wondering how it's made up. For example, is it made by…
BubbleMonster
  • 1,366
  • 8
  • 32
  • 48
1
vote
1 answer

Using concurrency in nested for loop? (Brute force)

I'm adapting code from a C program I made in class & I'm trying to convert all the programs I've written in C into Go in order to learn the language. I'm not quite "getting" concurrency yet though. How would I apply concurrency to a nested for loop?…
1
vote
1 answer

crack short password with brute force: nested for loop

I am trying to crack passwords of maximum 4 letters, from a hash. Ideally I can write ./crack 50fkUxYHbnXGw and it returns rofl. My approach is with a nested for loop. To apply this to strings of varying lengths I have been recommended to use a…
Tarae
  • 67
  • 2
  • 7
1
vote
1 answer

Function crypt() doesn't return the hash value in PHP 7.0

I had something like this (copied from http://www.gregboggs.com/php-blowfish-random-salted-passwords/) $Blowfish_Pre = '$2a$05$'; $Blowfish_End = '$'; $bcrypt_salt = $Blowfish_Pre . $salt . $Blowfish_End; …
Vu TrongNghia
  • 140
  • 2
  • 9
1
vote
1 answer

What is openwall crypt_r's data parameter?

char *crypt_r(const char *key, const char *setting, void *data) What is one supposed to pass as data argument? I can't find the docs for this. The Linux version uses the crypt_data type but that's not available in this…
XTF
  • 1,091
  • 1
  • 13
  • 31
1
vote
2 answers

Can mcrypt perform the same algorithms supported by crypt()?

I have an app that runs on PHP 5.3 which stores passwords hashed using PHP's crypt() function. However the hashing type (SHA 512) used is not available by default on one of the servers I'm now using which runs PHP 5.2. I've seen that with mcrypt you…
Naatan
  • 3,424
  • 4
  • 32
  • 51
1
vote
0 answers

decrypt data before making mysql query laravel 5

I have a db table called CardNumbers, the data has been encrypted using Crypt::encrypt(). I have a search box that i want to be able to search CardNumbers, but the data is encrypted. How do i decrypt it in my query in mysql. This is what i am…
ALCHI
  • 75
  • 1
  • 8
1
vote
1 answer

How to match crypted password in php while login?

I am using PHP crypt(). Here I saved my password using crypt(). In login, I want to match my password with the input password and logged in password, but in crypt its everytime creating random string with the same password. below is my login…
sradha
  • 2,216
  • 1
  • 28
  • 48
1
vote
0 answers

bcrypt using in laravel and python

I am using bcrypt in laravel with round 10 for password and now i want to access my site from django framework and want to check password from there when i hit with this sting 123456 it return me:…
Harman
  • 1,703
  • 5
  • 22
  • 40
1
vote
2 answers

Mysql encrypt sometimes returns null

Why the first and last command line returns null?? $ mysql -u root -ppass -Bse "SELECT ENCRYPT('p@ssW0rd', 'ñsñsñsñ');" NULL $ mysql -u root -ppass -Bse "SELECT ENCRYPT('p@ssW0rd', 'dafdadsfe');" dac0rB9hTC86M $ mysql -u root -ppass -Bse "SELECT…
David
  • 2,741
  • 16
  • 26
1
vote
1 answer

How to use CPasswordHelper in yii2

I am trying to encrypt a password using the PHP crypt function. In yii, it's recommended to use CPasswordHelper. When I call CPasswordHelper::hashPassword($password), it says Class 'common\models\CPasswordHelper' not found. Please help?
DSEJ
  • 131
  • 4
1
vote
1 answer

Module in list can't be imported

I know that this could be marked as a duplicate, but hear me out! The questions like this one are horribly out of date and no longer apply to my needs! I used help("Modules")to get a list of all installed modules. The module I was looking for,…
User9124
  • 13
  • 3
1
vote
1 answer

Does it matter what the salt is?

I want to use a blowfish crypt() in php but I am scared that i will use a wrong salt. Is there something like a wrong salt? And is a salt that is for instance 2020352352 worse than salt that is lkfjaslj5l3k? I know you should put something random in…
Ian.V
  • 345
  • 3
  • 19
1
vote
1 answer

Can I store hashed phone number and send it unhashed to email?

I have a task for my new PHP job, but I don't understand if it is possible to solve. Task: You need to create PHP web page that implements functional on picture below. Data must be stored in SQL. Hacker can not see user phone numbers and emails…
sirjay
  • 1,767
  • 3
  • 32
  • 52