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

MD5 hashing Algorithm step 2 and 3

I created a repository on github to write some of the computer security algorithms, and it's time to write MD5 Algorithm, i searched about papers/videos explain the algorithm with examples alongside steps, but i didn't. I wrote this for step 1 and…
Zeyad Etman
  • 2,250
  • 5
  • 25
  • 42
-2
votes
2 answers

C - crypt() - Code takes longer to execute with 5 loops or more than with 4 loops but using the same parameter/hash

I'm taking an edx course called CS50. Maybe some of you are familiar with it. One of the problems set asks you to implement an algorithm to crack a password that was hashed using des-based encryption and is up to 4 characters. So far, so good. I've…
Cam Moreira
  • 352
  • 1
  • 4
  • 13
-2
votes
1 answer

PHP Crypt Function with User input

So I was looking at the PHP Crypt Function and I was wondering if you could make this into a user input form type deal. Like This so when they submit the whatever they entered it will output the crpyt() function after they submit it and crpyt…
ItsMe
  • 1
-2
votes
1 answer

Password handling with MD5 and CRYPT isn't working as expected

What I am trying to do is self explanatory: I get a "username" and a "password" set by a user, and try to encrypt it. Here's what I've tried so far: //Firstly i recieve user and…
-2
votes
2 answers

how to do crypt and password_hash in php 5.6

hi can anyone tell me how to use crypt() and and password_hash in php 5.6 please? because i tried and it keeps on giving me this error Notice: crypt(): No salt parameter was specified. You must use a randomly generated salt and a strong hash…
nickyjack
  • 35
  • 1
  • 4
-2
votes
2 answers

How can I make Python program read line in file

I have 2 files, passwd and dictionary. The passwd is a test file with one word, while the dictionary has a list of a few lines of words. My program so far reads and compares only the first line of the dictionary file. For example. My dictionary file…
Onlytito
  • 167
  • 1
  • 2
  • 17
-2
votes
2 answers

Stronger Password Encryption using crypt()

So I am very interested in password encryption. I have created the below script and wanted some feedback as to see if it is a legitimate way to verify/secure a password, or if it simply isn't helping any. Any feedback is welcome: $pass =…
Matt Himsl
  • 49
  • 5
-3
votes
2 answers

Decrypt code , from ruby to js

does anyone know how to translate below ruby script to javascript? source = ENCRYPTED_STRING cipher = OpenSSL::Cipher::Cipher.new('AES-128-ECB') cipher.decrypt cipher.key = ['SECRET'].pack('H*') decoded = Base64.decode64(source) decrypted =…
George
  • 224
  • 3
  • 10
-3
votes
1 answer

How to safety store passwords in mysql to decrypt them later in php, not hash?

Needed to store passwords in mysql from other services. Hash not work, i needed to decryt passwords. How to safety to do that? Only that i think safe way is to use hardware token with decrypt key? Is there any other issues? Sorry my bad English.
-3
votes
2 answers

best way to store sensitive data php encryption

Hello so obviously this is not a question with code, I am very familiar with salt and md5 encryption in php. But I need a safe way to store sensitive information in mysql. using md5 its very simple but again not the safest way. any suggestion or…
cppit
  • 4,478
  • 11
  • 43
  • 68
-4
votes
1 answer

PHP password function

will this function be safe for password and email hash/crypt? EDIT: Cleary not! $password = mysql_real_escape_string(htmlspecialchars(trim($_POST['password']))); $hash_algo = "sha512"; $raw_output = false; $hash = hash($hash_algo, $password,…
Ruble Gomes
  • 117
  • 1
  • 7
-5
votes
1 answer

Why does my crypt package give me invalid magic prefix error?

I have the following code: import "github.com/kless/osutil/user/crypt/sha512_crypt" c := sha512_crypt.New() hash, err := c.Generate([]byte("enter-new-password"), []byte("$2a$09$f5561d2634fb28a969f2dO8QeQ70f4bjCnF/.GvPpjj.8jgmtzZP2")) if err != nil…
John
  • 32,403
  • 80
  • 251
  • 422
-6
votes
2 answers

Why I got this error passing a array element to crypt()

i got 2 error messages for the code, I tried to figure it out myself searching online but it didn´t help. the message are like this: error: incompatible integer to pointer conversion passing 'char' to parameter of type 'const char *'; take the…
Luis
  • 1
  • 1
1 2 3
36
37