man pages section 3: Basic Library Functions
  Search only this book
View this book in:
Download this book in PDF (3779 KB)

crypt(3C)

Name | Synopsis | Description | Return Values | Errors | Usage | Attributes | See Also

Name

    crypt– string encoding function

Synopsis

    #include <crypt.h>
    
    char *crypt(const char *key, const char *salt);

    Standard conforming

      #include <unistd.h>
      
      char *crypt(const char *key, const char *salt);

Description

    The crypt() function encodes strings suitable for secure storage as passwords. It generates the password hash given the key and salt.

    The key argument is the plain text password to be encrypted.

    If the first character of salt is “$”, crypt() uses crypt.conf(4) to determine which shared module to load for the encryption algorithm. The algorithm name crypt() uses to search in crypt.conf is the string between the first and second “$”, or between the first “$” and first “,” if a “,” comes before the second “$”.

    If the first character of salt is not “$”, the algorithm described on crypt_unix(5) is used.

Return Values

    Upon successful completion, crypt() returns a pointer to the encoded string. Otherwise it returns a null pointer and sets errno to indicate the error.

    The return value points to static data that is overwritten by each call.

Errors

    The crypt() function will fail if:

    EINVAL

    An entry in crypt.conf is invalid.

    ELIBACC

    The required shared library was not found.

    ENOMEM

    There is insufficient memory to generate the hash.

    ENOSYS

    The functionality is not supported on this system.

Usage

    The values returned by this function might not be portable among standard-conforming systems. See standards(5).

    Applications should not use crypt() to store or verify user passwords but should use the functions described on pam(3PAM) instead.

Attributes

    See attributes(5) for descriptions of the following attributes:

    ATTRIBUTE TYPE 

    ATTRIBUTE VALUE 

    Interface Stability 

    Standard 

    MT-Level 

    MT-Safe 

See Also

SunOS 5.10  Last Revised 28 Sep 2004

Name | Synopsis | Description | Return Values | Errors | Usage | Attributes | See Also