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

What's the point of storing a password's salt?

With Blowfish, what's the point of storing the salt since we can extract it from the hash? $hash = crypt($password, $salt); To get the hash we can use substr($hash, 0, 28) or substr($hash, 0, 29) I don't know if the dot is from the salt or the…
Vilarix
  • 735
  • 1
  • 10
  • 16
1
vote
1 answer

PHP's crypt function (STD_DES) in javascript

Is there an implementation of the crypt function in PHP written in javascript? I only need the STD_DES version eg. PHP: JS: console.log(PHP_crypt('test', 'SO')); // SOVYikZv1wMH. I…
Tyilo
  • 28,998
  • 40
  • 113
  • 198
1
vote
2 answers

Need help with brute force code for crypt(3)

I am trying to develop a program in C that will "crack" the crypt(3) encryption used by UNIX. The most naive way to do it is brute forcing I guess. I thought I should create an array containing all the symbols a password can have and then get all…
user212955
1
vote
1 answer

split private key(k1) such that only any two keys are necessary to decrypt it?

I encrypt data using public key(k1). I decrypt it using private key pk1 Is it possible to split private key(pk1) into keys pk2, pk3, pk4 and pk5 in such a way that only any two keys are necessary to decrypt it? Thanks.
user560913
  • 315
  • 2
  • 6
  • 17
1
vote
1 answer

Understanding PHP crypt() return value

PHP crypt function is said to have this return value: "Returns the hashed string or a string that is shorter than 13 characters and is guaranteed to differ from the salt on failure." I don't understand what this means... I've understood basically…
fast-reflexes
  • 4,891
  • 4
  • 31
  • 44
1
vote
2 answers

Site login with PHP MySQL Blowfish

I am having a serious issue with trying to validate my password when logging into my site. I am using php to create a blowfish encrypted password with salt using the code below.
PHaeLiX
  • 85
  • 1
  • 12
1
vote
1 answer

PHP storing password with blowfish & salt & pepper

I want to store secure user passwords in a MySQL database with PHP. How can I make it better? My Class: private static $algo = '$2a'; private static $cost = '$10'; private static $pepper = 'eMI8MHpEByw/M4c9o7sN3d'; public static function…
veriox
  • 23
  • 1
  • 3
1
vote
1 answer

how to get public key with Crypt_RSA

I have coded a simple test, but it sent me: "Unverified", I guess because I am using the whole certificate instead of the public key. What method gives me public key? $rsa = new Crypt_RSA(); $rsa->setPassword('here I include…
user1873420
  • 101
  • 1
  • 2
  • 7
1
vote
1 answer

Can't get crypt to work correctly

I was just messing around seeing if I could use the 'crypt' module and I've seem to run into a problem that I can't for the life of me figure out. The output after I run this is this: Password Not Found. secret HXXxJi0n6Huro HXXxJi0n6Huro Which…
Russ Adams
  • 73
  • 7
1
vote
2 answers

Do I need base64 encode my salt (for hashing passwords)?

Excuse me for this very odd question. I understand the purpose of base64 encoding for transmitting data (i.e. MIME's Base64 encoding), but I don't know if I need to base64 encode my salts. I wrote an utility class (a base abstract class indeed): use…
gremo
  • 47,186
  • 75
  • 257
  • 421
1
vote
1 answer

Python crypt package: Can type extra characters in password

I'm using Python's crypt package to persist encrypted passwords in a MySQL databse for a Django website. I'm not sure if this is a bug, but here's the code I'm using: To encrypt/persist the password: user.password = crypt(request.POST['password'],…
Matt Stern
  • 717
  • 11
  • 23
1
vote
3 answers

SHA256-CRYPT / SHA512-CRYPT in node.js

I use dovecot as my mail transfer agent and I aim to use the strongest password scheme which is supported by my system: SHA512-CRYPT or SHA256-CRYPT (BLF-CRYPT doesn't work). For my own written webinterface I look for a function or library in…
ChristophLSA
  • 175
  • 3
  • 19
1
vote
1 answer

Using crypt_r on OS X

I want to use the crypt_r function on Mac OS X 10.8.2 #define _GNU_SOURCE #include produces crypt.h: No such file or directory Where can I get the crypt.h file from? Or am I including it wrong? Edited question - concrete…
kadrian
  • 4,761
  • 8
  • 39
  • 61
1
vote
2 answers

PHP mcrypt_get_iv_size () for Salt Size Generation

I am writing a PHP script to authenticate users. I want to use SHA512 for the hash and use a salt to prepend to the password. To generate the salt, I want to use mcrypt_create_iv. But first, I must figure out the initialization Vector size. For…
dman
  • 10,406
  • 18
  • 102
  • 201
1
vote
2 answers

crypt function returning different results with same salt,password and blowfish

I have started to work on making a login system and using the crypt function for the encoding of passwords. My problem is that when I register the user with there user and password it all works and saves the username password and salt to the…
Matthew
  • 195
  • 2
  • 2
  • 18