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

Python Enter Password And Compare to Shadowed Password Database

Good Day. Im trying to write a python script that will take a captured password then compare it to the system shadowed password. Im using Ubuntu 12.10 for this test. and running the script as sudo. def login(user, password): "Check if user would…
SAShapeShifter
  • 149
  • 3
  • 11
2
votes
2 answers

Java strong encryption - standalone library- source code only

I am looking for a Java based encryption library with support for strong encryption. I am aware of the Java Cryptography Extension but to use it I would like to access the source code first, modify those, compile them and use my own version of them…
mjs
  • 21,431
  • 31
  • 118
  • 200
2
votes
1 answer

`password_verify` call returning false for correct password

I have the following snippet of code: // bcrypt hash of 'password' $hash = '$2y$10$4u0cQ.WEnwHDo.C5Nl1vm.shKA0beQ32wqzphSfzklAq9OcDM2nLu'; if(password_verify('password', $hash)) { print_r('woohoo!'); } else { print_r('fubar'); } On one…
Matt
  • 9,068
  • 12
  • 64
  • 84
2
votes
1 answer

Combining static and random salts

Possible Duplicate: Improve password hashing with a random salt Is there a valid security reason to generate random salt, but then store it in the same DB as the password as well as a static salt? For example: $hashedPass = crypt($pass,…
boruch
  • 453
  • 3
  • 16
2
votes
5 answers

PHP Crypt() Compare two crypted strings

Is it possible to compare two cryptDocs-ed strings and see if they match? A user logs in, a session is created storing the user's ID and its corresponding crypt-ed password hash. In the background a check keeps running to see if the session (read,…
Roel
  • 754
  • 3
  • 13
  • 30
2
votes
1 answer

What am I doing wrong with this crypt()-based bcrypt authentication?

I've cribbed this code almost verbatim from a bunch of very helpful answers here on SO, so I can't get my head around what's wrong. First, here's my function for creating a user account: function BFcrypt($password,$cost) { …
Polisurgist
  • 340
  • 2
  • 11
2
votes
1 answer

what is the best time i can get for registration operation in python?

in registration operation, there is a password crypt which as i understand can't parallelized since if it makes an operation of a key derivation (PBKDF2 for example), then it needs the previous value, then i guess it is a linear operation? Making…
Abdelouahab Pp
  • 4,252
  • 11
  • 42
  • 65
2
votes
2 answers

PHP crypt function password encoding

The following code returns the same encrypted password whichever way round. Why and how do we stop this. $pwd = 'shits8888'; $salt = '50153fc193af9'; echo crypt($pwd,$salt) Obviously something is missing as this is returning the same thing $pwd =…
Walrus
  • 19,801
  • 35
  • 121
  • 199
2
votes
1 answer

to use CRYPT_BLOWFISH on php 5.2 that doesn't support it

I am running my page on PHP 5.2 that does not support CRYPT_BLOWFISH but CRYPT_MD5, and have heard that the blowfish is much more safer than md5. Since I am not the supervisor thing, I can not upgrade PHP to a version that supports it. Is there…
Hoon
  • 1,571
  • 5
  • 15
  • 19
2
votes
2 answers

Using base64_encode when using PHP's crypt() function

I have a quick question for you guys: I am tinkering with PHP (I am relatively inexperienced), and am interested in developing a secure password hashing system for use on my site. Through other articles and questions on SO, I have surmised that I…
NCourts
  • 23
  • 2
2
votes
1 answer

Perl crypt seemingly not working

I am trying to use the crypt function to verify a user's details in database: my $sql = $dbh->prepare("SELECT COUNT(id) FROM tblUsers WHERE UPPER(Username)=UPPER(?) AND Password=?"); my $count; $sql->execute( …
skeniver
  • 2,647
  • 6
  • 28
  • 34
1
vote
3 answers

PHP: Minify crypted value

Is it possible, to transform a crypted string (similar to md5), without loosing the ability of decoding it back again? 0TJyj0wX4ZCrsYlANG8QgwBHnGzGU7kr1BEkolr6tY0OdowpA== Better: 73a4842f36b4n237m64as23
mate64
  • 9,876
  • 17
  • 64
  • 96
1
vote
2 answers

Verify digital signature within system32/drivers folder

I've spent all night researching this without a solution. I'm trying to verify the digital signature of a file in the drives folder (C:\Windows\System32\drivers*.sys) pick whatever one you want. I know that the code is correct because if you move…
SNyamathi
  • 658
  • 6
  • 10
1
vote
2 answers

PHP Crypt not working Ubuntu PHP 5.3.6

Why do the crypt values not match on Ubuntu PHP 5.3.6? On other systems, they match. Sample code:
David Barnes
  • 2,138
  • 5
  • 19
  • 25
1
vote
2 answers

Why should't I use an encryption salt I enter myself and use a function to randomize a salt for me?

I am just typing a salt and on php documentations, people always use some random variable function. What is the disadvantage of typing a salt instead of generating it?
Uğur Gümüşhan
  • 2,455
  • 4
  • 34
  • 62