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

Perl Crypt::CBC don't return the expected result

I'm looking at the Crypt::CBC lib and I misunderstand something... below an example : #!/usr/bin/env perl use warnings; use strict; use Crypt::CBC; my $cipher = Crypt::CBC->new( -key => pack("H*","0011223344556677"), -iv =>…
0x0ff.info
  • 11
  • 4
1
vote
1 answer

Freeradius radcrypt encryption in PHP

I'm looking for a solution in PHP Similar to the output of radcrypt. I've looked into mcrypt and can't seem to figure out which cipher and setting i should use. Mcrypt wants a salt to add to the encryption but radcrypt doesn't seem to have a…
Benjamin de Bos
  • 4,334
  • 4
  • 20
  • 30
1
vote
0 answers

weird code in my host "stole my ID database"

I found a weird code in my host, and when I saw log of this code, I found…
JFouad
  • 551
  • 6
  • 12
1
vote
2 answers

Installing Apache with Cygwin

I'm trying to use Cygwin to install Apache, but I keep running into an error that I can't find a solution to. I'm following the instructions on the official Apache site for installing Apache 2.4 on a UNIX-like system, I downloaded the tar.gz version…
HartleySan
  • 7,404
  • 14
  • 66
  • 119
1
vote
1 answer

PHP crypt validation with PDO prepared statement Error

and sorry for the [duplicate]. i spent a day, not able to find a solution. I am having a problem with crypt (validation), here is my code: function generateHash($password, $round=10){ …
user3281766
  • 33
  • 1
  • 6
1
vote
1 answer

Determining the salt from a password_hash()

I'm hashing my password with bcrypt (actually with password_compat since I run php 5.3.10) I wanted to split the result string of the function into two parts: the salt used and the hash itself. (I know to use password_verify() to verify, well, the…
stUrb
  • 6,612
  • 8
  • 43
  • 71
1
vote
1 answer

DES and ICryptoTransform

This method works fine in a program I've made. However I cannot really understand what is happening and where the encryption is actually performed. I read the related description from MSDN but not much information is given. Can someone explain what…
user2307236
  • 665
  • 4
  • 19
  • 44
1
vote
1 answer

PHP passwordhash from MD5() to crypt() Blowfish

I've used MD5() password hashing in an old application and I want to switch to crypt() hashing since its more secure. But... I don't have any experiance with the crypt() function. So now for hashing I have this: function hashPassword($uPassword)…
DigiLive
  • 1,093
  • 1
  • 11
  • 28
1
vote
3 answers

PHP crypt problems

A quick and dirty experiment. I put this code into a .php file and loaded it from my web host. The result was "It works!" but.. why? Should it have failed? I was following Example #1 from here:…
James
  • 538
  • 1
  • 6
  • 23
1
vote
2 answers

Is freebsd C crypt() threadsafe?

When I read BUGS The crypt() function returns a pointer to static data, and subsequent calls to crypt() will modify the same data. Likewise, crypt_set_format() modifies static data. from:…
dhein
  • 6,431
  • 4
  • 42
  • 74
1
vote
1 answer

how can i use cryptimportkey function import a private key to encrypt data same result use imported key

I use some win32 api create a pravite/public key pair and write them to files. that i do: CryptGenKey(hProv, CALG_RSA_KEYX, KEYLENGTH | CRYPT_EXPORTABLE | CRYPT_NO_SALT, &hSessionKey); // export private key buffer and write it to file …
bruceLi
  • 11
  • 1
  • 2
1
vote
1 answer

CryptoJS and PHP SHA256

I would like to get Both CryptoJS's SHA256 and php's Crypt SHA256 output to match. PHP crypt has a salt and a number of rounds. E.g. for 5000 rounds and salt of "usesomesillystringforsalt" it would be; $hash = crypt('Clear Text String',…
leenix
  • 76
  • 1
  • 7
1
vote
2 answers

Checking every "word" from aaa..a to zzz..z

My program is supposed to be a brute force password cracker (school assignment). The input arguments are as follows.. ./crack threads keysize target The program needs to check passwords of length keysize, but also need to check shorter ones. I am…
m96
  • 199
  • 1
  • 3
  • 10
1
vote
1 answer

"can't convert string into integer" error in crypt/blowfish in rails3

Migrating an application from rails2 to rails3 and i am facing an error can't convert String into Integer in crypt/blowfish. config/core_ext/string.rb file: def encrypt(key)
blowfish = Crypt::Blowfish.new(key) …
1
vote
1 answer

PHP crypt salt generation

I am generating salt for php crypt function like this $hashSalt = substr(md5(time().uniqid(rand())),0, 22); $hashedPassword = crypt('SmithJohn', '$2a$07$'.$hashSalt.'$'); From my understanding this is a good method. What are your thoughts?
phantomCoder
  • 1,499
  • 3
  • 18
  • 32