转自:http://www.ualberta.ca/dept/chemeng/AIX-43/share/man/info/C/a_doc_lib/libs/commtrf1/cbc_crypt.htm
Purpose
Implements Data Encryption Standard (DES) encryption routines.
Library
Syntax
# include <des_crypt.h>
int ecb_crypt (key, data, datalen, mode)
char *key; char *data; unsigned datalen; unsigned mode;
int cbc_crypt(key, data, datalen, mode, ivec)
char *key; char *data;
unsigned datalen; unsigned mode; char ivec;
void des_setparity(key) char *key;
Description
The ecb_crypt and cbc_crypt subroutines implement DES encryption routines, set by the National Bureau of Standards.
- The ecb_crypt subroutine encrypts in ECB (Electronic Code Book) mode, which encrypts blocks of data independently.
- The cbc_crypt subroutine encrypts in CBC (Cipher Block Chaining) mode, which chains together successive blocks. CBC mode protects against insertions, deletions, and substitutions of blocks. Also, regularities in the clear text will not appear in the cipher text.
Note: The DES library must be installed to use these subroutines.
Parameters
Return Values
Note: Given the stat variable, for example, which contains the return value for either the ecb_crypt or cbc_crypt subroutine, the DES_FAILED(stat) macro is false only for the DESERR_NONE and DESERR_NOHWDEVICEreturn values.
Implementation Specifics
These subroutines are not available for export outside the United States.
Files
/usr/include/des_crypt.h | Defines macros and needed symbols for the mode parameter. |