crypt()

Hash a password

Synopsis:

#include <unistd.h>

char * crypt( const char * key, 
              const char * salt );

Arguments:

key
A NUL-terminated string (normally a password typed by a user).
salt
A two-character string chosen from the set [a-zA-Z0-9./]. This function doesn't validate the values for salt, and values outside this range may cause undefined behavior. This string is used to perturb the algorithm in one of 4096 different ways.

Library:

liblogin

Use the -l login option to qcc to link against this library.

Note: We've deprecated the version of this function in libc. You should link against liblogin if your application authenticates users against the /etc/passwd and /etc/shadow files.

Description:

The crypt() function hashes a password. It's based on the Data Encryption Standard algorithm, and also includes code to deter key search attempts.

Note: This function checks only the first eight characters of key.

The algorithm obtains a 56-bit key by taking the lowest 7 bits of the first eight characters of key. The 56-bit key is used to repeatedly hash a constant string (usually all zeroes).

For license information, see the Third Party License Terms List at http://licensing.qnx.com/third-party-terms/.

Returns:

A pointer to the 13-character hashed value, or NULL on failure. The first two characters of the hashed value are the salt itself.

Note: The return value points to static data that's overwritten by each call to crypt().

Classification:

POSIX 1003.1 XSI

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread No