CRYPT(3)                       Library Routines                       CRYPT(3)


       crypt, setkey, encrypt, - simple encryption


       #include <unistd.h>

       char *crypt (const char *key, const char *salt);
       int setkey (char *key);
       int encrypt (char *block, int flag);


       The crypt function performs password encryption.  It is derived from an
       algorithm given in Computer Networks by Andy Tanenbaum.

       The first argument to crypt (key) is a NULL-terminated string (normally
       a  password  typed  by  a  user).  The second, salt, is a two-character
       array that should be randomly generated by the caller in  the  case  of
       encrypting  a new password, or should be taken as the first two charac-
       ters of the /etc/passwd password entry in  the  case  of  validating  a

       The  functions,  encrypt and setkey allow limited access to the encryp-
       tion algorithm itself.  The key argument to setkey is  a  64  character
       array  of binary values (numeric 0 or 1).  A 56-bit key is derived from
       this array by dividing the array into groups of 8 and ignoring the last
       bit in each group.

       The  encrypt argument block is also a 64 character array of binary val-
       ues.  If the value of flag is 0, the argument block is encrypted,  oth-
       erwise  it  is  decrypted.  The encryption or decryption is returned in
       the original array block after using the key  specified  by  setkey  to
       process it.

       The  function  crypt returns a pointer to the encrypted value (which is
       formatted as printable ASCII characters) on success and NULL  on  fail-
       ure.   The  functions  setkey  and encrypt return 0 on success and 1 on

       Use of these routines requires linking with the libcrypt library.


       login(1), passwd(1), getpass(3), passwd(5)

              Mathematical Cryptology for Computer Scientists  and  Mathemati-
              cians by Wayne Patterson.  1987.  Volume ISBN 0-8476-7438-X.

              Password  Security:  A  Case History by R. Morris, Ken Thompson.
              Communications of the ACM, vol. 22, pp. 594-597.  November 1979.

              DES  will  be Totally Insecure within Ten Years by M.E. Hellman.
              IEEE Spectrum, vol. 16, pp. 32-39.  July 1979.


       The crypt function leaves its result in an internal static  object  and
       returns  a pointer to that object.  Subsequent calls to crypt will mod-
       ify the same object.

GNO                             28 January 1997                       CRYPT(3)

Man(1) output converted with man2html