crypt, encrypt
Purpose
Encrypts user passwords.
Library
Standard C Library (libc.a)
Syntax
char *crypt (key, salt) void encrypt (block)
char *key, *salt; char *block;
Description
The crypt and encrypt subroutines encrypt user passwords.
They are based on a one-way hashing encryption algorithm
with variations intended to frustrate the use of
hardware-implemented key searches. These subroutines are
provided for compatibility with UNIX system implementa-
tions, and no assertion is made about the strength of the
algorithm.
The key parameter is a user's typed password. The salt
parameter is a two-character string chosen from the set
["a-zA-Z0-9./"].
The salt parameter is used to perturb the hashing algo-
rithm in one of 4096 different ways, after which the
password is used as the key to repeatedly encrypt a con-
stant string. The return value points to the encrypted
password. The first two characters of the return value
are the string entered in the salt parameter.
The crypt subroutine uses a character array of length 64
containing only the values "(char) 0" and "(char) 1".
This string is divided into groups of eight characters
each, and the low-order bit in each group is ignored.
This provides a 56-bit key, which is set into the machine
by crypt.
The encrypt subroutine provides somewhat primitive access
to the actual hashing algorithm. The block parameter is
a 64-character array containing only the values
"(char) 0" and "(char) 1". encrypt modifies this array
in place, producing a similar array that has been sub-
jected to the hashing algorithm using the key set by
crypt.
Return Value
The crypt subroutine returns a pointer to the encrypted
password. The first two characters of it are the same as
the salt parameter.
Note: The return value points to static data that is
overwritten by subsequent calls.
Related Information
In this book: "getpass" and "passwd."
The login and passwd commands in AIX Operating System
Commands Reference.