[Previous] [Contents] [Next]

crypt()

Encrypt a password

Synopsis:

#include <unistd.h>

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

Library:

libc

Description:

The crypt() function performs password encryption. It's based on the Data Encryption Standard algorithm, and also includes code to deter key search attempts. The key argument is a NUL-terminated string (normally a password typed by a user).


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

The salt is a two-character string chosen from the set [a-zA-Z0-9./]. Values for salt aren't validated by this function, and values outside this range may cause undefined behaviour. This string is used to perturb the algorithm in one of 4096 different ways.

A 56-bit key is obtained by taking the lowest 7 bits of key. The 56-bit key is used to repeatedly encrypt a constant string (usually all zeroes).

Returns:

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

Classification:

Unix

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

Caveats:

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

See also:

encrypt(), getpass(), qnx_crypt(), setkey()

login in the Utilities reference

Copyright © MINIX Operating System


[Previous] [Contents] [Next]