The password encryption function. Format #include <unistd.h> #include <stdlib.h> char *crypt (const char *key, const char *salt;)
1 – Function Variants
The crypt function has variants named _crypt32 and _crypt64 for use with 32-bit and 64-bit pointer sizes, respectively.
2 – Argument
key A user's typed password. salt A 2-character string.
3 – Description
The crypt function generates an encoded version of a password. It is based on the NBS Data Encryption Standard, with variations intended to frustrate use of hardware implementations of the DES for key search. The first argument to crypt is normally a user's typed password. The second is a 2-character string chosen from the set [a-zA-Z0- 9./]. The salt string is used to perturb the DES algorithm in one of 4096 different ways, after which the password is used as the key to encrypt repeatedly a constant string. The returned value points to the encrypted password, in the same alphabet as the salt. The first two characters are the salt itself. The return value from crypt points to a static data area whose content is overwritten by each call. See also encrypt and setkey.
4 – Return Value
pointer Pointer to the encrypted password.