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

How to Make a MediaWiki Password

How do I take a plaintext password and insert an entry in the MySQL database that MediaWiki uses, that would comply to MediaWiki's password rules? I found this article on how they store their passwords, but I can't seem to figure out how I can…
Eliter
  • 153
  • 2
  • 10
2
votes
1 answer

How to use crypt(3) in windows?

How can I invoke crypt(3) from a c program on a windows platform? I can't find a header file to include. I have MinGW with gcc and msys installed. Edit: as an alternative, I would also accept a way to call this function (or an equivalent) from…
Cephalopod
  • 14,632
  • 7
  • 51
  • 70
2
votes
1 answer

Cannot login with crypt password

I am developing login and registration function for an android app. I have checked many tutorial that set password as md5, but I want a more secure way. I use crypt() instead of md5. Howerver, I only can register and cannot login into application.…
Molly Molly
  • 125
  • 8
2
votes
0 answers

Different outputs from Crypt(3) and CryptoJS

I am hashing passwords in MariaDB using: ENCRYPT('password', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16)) Which produces something like: $6$3b502db443d64283$BNSYWsf3T0e4xT23GJW/QPpKvzLidio5zk9v7kCE.wk4dtNo4avMzBxvqoWc0Y5ihj/zVwtGCwZRfTFur0BnI1 The…
Daniel C
  • 1,332
  • 9
  • 15
2
votes
3 answers

Use of undefined constant CRYPT_SHA512

I use a php script that hashes passwords using php's crypt and uses SHA512, however when I try to check if SHA512 is set I get the above error. Of course I know WHY I get this error.. php is missing some dependency. I just don't know what that…
Naatan
  • 3,424
  • 4
  • 32
  • 51
2
votes
1 answer

How can I create an encrypted password for useradd using python crypt or bcrypt?

I'm trying to create a hashed password for debian/ubuntu useradd. I use python to create the hash and use bash to create the user with the hashed password. I think I'm doing something wrong because when I try to login with the user's password it…
answerSeeker
  • 2,692
  • 4
  • 38
  • 76
2
votes
3 answers

Python Usage of Crypt Function

How to implement the crypt option in Python 3? I understand that the use is: Hash = crypt.crypt(password, salt) However, the function has a set of different hashing functions. From the documentation: crypt.METHOD_SHA512 A Modular Crypt Format…
Tikhon
  • 451
  • 1
  • 5
  • 13
2
votes
0 answers

Laravel 5.1 Searching encrypt not working for me

I'm working on this model with name field encrypted using Crypt class, i can display data into decrypted in view. but when searching for the value in the model that is encrypted. my controller returns null. //heres my code: validator…
jp.palubs
  • 178
  • 1
  • 14
2
votes
0 answers

modify php source code (phpseclib) for pure phalanger mode

Hello everybody php and phalanger experts: I am mainly developing with c#. PART 0 I need to compile some third party php code (part of phpseclib Crypt, File, Math, Net pure php implementations, and some files using RSA with ctr cyphermode) with…
2
votes
1 answer

how is the salt for user password hash created when creating a new user, for use with crypt() after?

currently making a little analysis on the authentication based on password on linux, i understood the following : users passwords hashes are stored in /etc/shadow, with the salt used to generate them. The id also provide the algorithm used to get…
evoliptic
  • 333
  • 2
  • 11
2
votes
1 answer

What is the time complexity of crypt function in Linux?

The crypt function described as below in unix for authentication: char *crypt(const char *key, const char *salt); Assume that I have the key (of length n), and the salt (of length m), what is the time complexity (order of algorithm) of calling…
NaSh
  • 665
  • 5
  • 16
2
votes
2 answers

Perl Crypt:CBC encrypts/decrypts only first list

Here is my code: #!/usr/bin/perl -w use Crypt::CBC; my $scriptkey = qx(cat /tmp/scriptkeyfile); chomp $scriptkey; print new Crypt::CBC(-key=>"$scriptkey",-salt=>"my_salt")->encrypt(qx(cat $ARGV[0])); This script only encrypts first line of given…
2
votes
1 answer

How do I get this to decode (Perl cbc-crypt to C cbc_crypt conversion)

I'm trying to be able to decode encoded strings that were encoded using a perl script. The reason I can't just change the perl script is because a lot of important data already exists that was saved via the perl script and it would be too much to…
user5074403
2
votes
1 answer

Crypt function outputting two different values depending on PHP version

Using the password "testtest" and the hash "KFtIFW1vulG5nUH3a0Mv" with the following code results in different hashes depending on the PHP version (as shown in the image below): $salt = "KFtIFW1vulG5nUH3a0Mv"; $password = "testtest"; $key =…
JimmyBanks
  • 4,178
  • 8
  • 45
  • 72
2
votes
1 answer

When checking password, it only cares about the first 8 characters

I have a sign-up form that creates a profile and an "Edit Profile" page that allows the user to change information as long as they also enter their password. The problem is that the "Edit Profile" page only makes sure that the first 8 characters of…