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

Crypt_Blowfish backward compatibility from pear to phpseclib

I want to migrate my system from pear/Crypt/Blowfish to phpseclib/Crypt/Blowfish lib. I need to have a total backward compatibility. So, What are differences between these two libraries ? I found in this link that "PEAR's Crypt_Blowfish uses ECB by…
Rey0bs
  • 1,192
  • 12
  • 19
1
vote
1 answer

Password works even with extra characters

I have two methods that I am using. When a user creates an account I call this method to make a secure password hash for them to save into the database: public function createPassword($password){ $salt = hash("sha256", time() . uniqid() .…
Get Off My Lawn
  • 34,175
  • 38
  • 176
  • 338
1
vote
0 answers

C# to PHP decrypting

I need to decrypt inside a PHP project some strings that were encrypted with C# in a project. AFter some research i noticed that the C# project uses the Interop.ACECRYPTLib dll which looks like call it's a wrapper for the CRYPTLib dll... I have the…
Nathan
  • 24,586
  • 4
  • 27
  • 36
1
vote
1 answer

python crypt equivalent for windows

I am trying to find an equivalent function to UnixCrypt in Python for Windows. What I have found so far is that python does provide a crypt function, but it is only for Unix os. For Windows os, there are Cairnarvon's crypt.py, and passlib's…
pangyuteng
  • 1,749
  • 14
  • 29
1
vote
2 answers

error:FFFFFFFFFFFFFFFF:lib(255):func(4095):reason(4095) during RSA decyption

I'm trying to create a hybrid cryptography tool in C++ with Qt Gui. (The data will be encrypted with AES 256-CBC, the AES Key RSA encrypted and saved then.) But the RSA part of this tool doesn't work. I wrote the sourcecode several times but I…
H4ckHunt3r
  • 11
  • 2
1
vote
1 answer

Why does this source code using "crypt" have this compiler warning:

#include #define _XOPEN_SOURCE #include int main() { const char *key = NULL; const char *salt = NULL; crypt(key, salt); return 0; } use gcc test.c -o test -Wall -lcrypt to compile. Which gives this…
monkeyFly
  • 23
  • 6
1
vote
2 answers

how does salt works on crypt function in c?

I read the man crypt and didn't understand what the phrase below means: salt is a two-character string chosen from the set [a-zA-Z0-9./]. This string is used to perturb the algorithm in one of 4096 different ways.
user3872004
1
vote
2 answers

Java equivalent for PHP crypt with crypt key

I am trying to find a java equivalent for PHP crypt() function. I found it here, but the answer says nothing about crypting with a crypt key. I have a PHP website which uses md5 encryption and I have a datatable for users with their passwords…
Marko Cakic
  • 6,936
  • 9
  • 27
  • 34
1
vote
0 answers

Blowfish crypt(3) equivalent using OpenSSL?

I am trying to generate a one way password hash (Blowfish) in C using crypt library. However, the return hash is null for some reason. /* gcc -lcrypt crypt.c -o crypt ./crypt */ #include #include int main(int argc, char…
Flan Alflani
  • 2,065
  • 3
  • 15
  • 17
1
vote
1 answer

Crypting with php crypt()

I have this code
user3787755
1
vote
1 answer

Crypt, blowfish, and hashing

i bet there are scripts out there already about this, but I'm creating this project just for fun and to test my knowledge, now i just want the public's opinions, and if you guys find a way I could improve feel free to share as well to comment…
1
vote
1 answer

Possible to login without the digits in the password

I just discovered that my password-protected area is not that protected. Passwords are required to use digits. Now, if the password has the digits at the end, somehow the login is accepted as long as the a-z part of the password is correct. Why is…
pixeline
  • 17,669
  • 12
  • 84
  • 109
1
vote
1 answer

String comparison not working using php

Source of all of the follwoing lines : http://www.the-art-of-web.com/php/blowfish-crypt/ I use this method to check if my server accepts blowfish crypting : if(defined("CRYPT_BLOWFISH") && CRYPT_BLOWFISH) echo "CRYPT_BLOWFISH is enabled!
"; And…
Oliver
  • 23,072
  • 33
  • 138
  • 230
1
vote
0 answers

Why would crypt() return an asterisk?

I am building a login system using PHP and crypt(). The first time I ran it, crypt('some_password') returned a * (asterisk). I ran the script a few more times, but I could not get crypt to return another asterisk. What would cause this…
Hoytman
  • 1,722
  • 2
  • 17
  • 29
1
vote
1 answer

Match passwords after using CRYPT_BLOWFISH

I have successfully created my passwords and am inserting them into the database using CRYPT_BLOWFISH. However I do no know how to match the crypted passwords in the database to the passwords the user is entering to login. Any help is greatly…
bilcker
  • 1,120
  • 1
  • 15
  • 43