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

Can I publish salt of a password?

I have a PHP website storing user passwords encrypted and salted. Method used is crypt($password, $salt). Salt is generated randomly. Result is something like $2a$08$saltsaltsaltsaltsaltsaltsaHashHashHashHashHashHashHash Now I have to login to…
2
votes
1 answer

Generating crypt() sha512 hashes in Go

I am working on my authorization module in GoLang. Before we used PHP5 with the crypt function. The hash was generated like…
Michael Tijhuis
  • 173
  • 1
  • 10
2
votes
0 answers

JavaScript implementation of modern UNIX crypt(3)?

Is there a pure JavaScript library to encrypt passwords like the UNIX crypt(3), supporting modern encryption methods like SHA-256 or SHA-512? (e.g., crypt('password', '$6$salt') like in the crypt module of Python 3) In addition, I would also need…
Riccardo Murri
  • 1,045
  • 1
  • 11
  • 19
2
votes
0 answers

PHP Crypt blowfish output and Python crypt differs

Have created a hashed password using crypt in PHP and want same hashed out in Python using crypt module. How can I do that? Here is my PHP Code: function generateSalt($cost = 10) { if (!is_numeric($cost) || $cost < 4 || $cost > 31) { …
Vin.AI
  • 2,369
  • 2
  • 19
  • 40
2
votes
7 answers

Rehashing passwords without asking all users to change them

A former developer used the PHP hash() function with the SHA256 algorithm to store password hashes. To improve the security of the system, I'd like to start using crypt() with the Blowfish algorithm (unfortunately we don't have PHP 5.5 and thus…
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
2
votes
1 answer

PHP crypt returns true even with suffix behind password

So i have a small leak in my login script. lets say we have a user "David" with the password "s3cret". If David logs in with s3cret, he is logged in, and everything works fine. If he logs in with "oijopij", the system won't give him access, as…
David
  • 1,227
  • 12
  • 23
2
votes
2 answers

Linux login via node.js

I'm currently building an (experimental) webapp to login and control a (linux) server (especially for monitoring) in node.js. For authentification i would like to use the linux users. Either via /etc/passwd and /etc/shadow, reading information…
bbuecherl
  • 1,609
  • 12
  • 20
2
votes
1 answer

How to use crypt() on freeBSD with sha512?

Currently my code looks like this: if (iInit == 1) { if (crypt_set_format("sha512") == 0) return -1; iInit = !iInit; } res = crypt(szPWhash, "ABCDEFGH"); The resulting hash is € v I tryed already res = crypt(szPWhash,…
dhein
  • 6,431
  • 4
  • 42
  • 74
2
votes
2 answers

Is it secure for the string and salt to be the same with crypt() in a password?

As in, say someone gets access to the hash "PafgokWMoHSZE". Because this has been obtained through crypt(Password1,Password1) would it be any easier/harder to reverse engineer than any other salt?
2
votes
1 answer

node.js rsa encryption/decryption

I have the following C# code: // incoming data - MemoryStream memoryStream RSACryptoServiceProvider cryptoServiceProvider1 = new…
CnApTaK
  • 21
  • 1
  • 2
2
votes
1 answer

Is this the right way to store passwords in database and activate user accounts?

I'm building a website with HTML5, CSS, JavaScript, PHP and MySQL DB. I've created a login page and a 'create new user page' and would like to have an email send to active the user account. What I've built now is working but I would like to verify…
Gabrie
  • 537
  • 1
  • 5
  • 15
2
votes
1 answer

how to use security features in Zend framework 2?

Are there specific examples of the use of cryptographic tools from Zend \ Crypt? Examples are used Zend \ Crypt in modules? On the official site says only the basic use of these properties. For example when I want to record and encrypt the data (not…
V.Holovka
  • 113
  • 1
  • 2
  • 13
2
votes
2 answers

Bcrypt with PHP 5.4.16 - level of work

I am looking to implement BCrypt into a web application, however I am left lost in how to incorporate / change the level of work / iterations/rounds: php.net crypt function states As of PHP 5.3.0, PHP contains its own implementation. I understand…
Gravy
  • 12,264
  • 26
  • 124
  • 193
2
votes
1 answer

Crypto++ multibyte/unicode issue

I'm using Crypto++ library in my project but I've the following message: In memory integrity check failed. This may be caused by debug breakpoints or DLL relocation. And Visual Leak Detector detect lots of memory leaks, but I'll dctor are…
Elvis Dukaj
  • 7,142
  • 12
  • 43
  • 85
2
votes
2 answers

PHP Crypt() versus Python's Crypt() For Hashing

I am comparing PHP's crypt() versus Pythons crypt(). From Reading Python's manual: http://docs.python.org/2/library/crypt.html Platforms: Unix This module implements an interface to the crypt(3) routine, which is a one-way hash function based…
dman
  • 10,406
  • 18
  • 102
  • 201