Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

encrypt(2) [plan9 man page]

ENCRYPT(2)							System Calls Manual							ENCRYPT(2)

NAME
encrypt, decrypt, netcrypt - DES encryption SYNOPSIS
#include <u.h> #include <libc.h> int encrypt(void *key, void *data, int len) int decrypt(void *key, void *data, int len) int netcrypt(void *key, void *data) DESCRIPTION
Encrypt and decrypt perform DES encryption and decryption. Key is an array of DESKEYLEN (defined as 7 in <auth.h>) bytes containing the encryption key. Data is an array of len bytes; it must be at least 8 bytes long. The bytes are encrypted or decrypted in place. The DES algorithm encrypts an individual 8 byte block of data. Encrypt uses the following method to encrypt data longer than 8 bytes. The first 8 bytes are encrypted as usual. The last byte of the encrypted result is prefixed to the next 7 unencrypted bytes to make the next 8 bytes to encrypt. This is repeated until fewer than 7 bytes remain unencrypted. Any remaining unencrypted bytes are encrypted with enough of the preceding encrypted bytes to make a full 8 byte block. Decrypt uses the inverse algorithm. Netcrypt performs the same encryption as a SecureNet Key. Data points to an ASCII string of decimal digits with numeric value between 0 and 10000. These digits are copied into an 8 byte buffer with trailing binary zero fill and encrypted as one DES block. The first four bytes are each formatted as two digit ASCII hexadecimal numbers, and the string is copied into data. SOURCE
/sys/src/libc/port DIAGNOSTICS
These routines return 1 if the data was encrypted, and 0 if the encryption fails. Encrypt and decrypt fail if the data passed is less than 8 bytes long. Netcrypt can fail if it is passed invalid data. SEE ALSO
securenet(8) BUGS
The source is not included in public distributions. The implementation is broken in a way that makes it unsuitable for anything but authentication. ENCRYPT(2)

Check Out this Related Man Page

DES(3)							User Contributed Perl Documentation						    DES(3)

NAME
Crypt::DES - Perl DES encryption module SYNOPSIS
use Crypt::DES; DESCRIPTION
The module implements the Crypt::CBC interface, which has the following methods blocksize =item keysize =item encrypt =item decrypt FUNCTIONS
blocksize Returns the size (in bytes) of the block cipher. keysize Returns the size (in bytes) of the key. Optimal size is 8 bytes. new my $cipher = new Crypt::DES $key; This creates a new Crypt::DES BlockCipher object, using $key, where $key is a key of "keysize()" bytes. encrypt my $cipher = new Crypt::DES $key; my $ciphertext = $cipher->encrypt($plaintext); This function encrypts $plaintext and returns the $ciphertext where $plaintext and $ciphertext should be of "blocksize()" bytes. decrypt my $cipher = new Crypt::DES $key; my $plaintext = $cipher->decrypt($ciphertext); This function decrypts $ciphertext and returns the $plaintext where $plaintext and $ciphertext should be of "blocksize()" bytes. EXAMPLE
my $key = pack("H16", "0123456789ABCDEF"); my $cipher = new Crypt::DES $key; my $ciphertext = $cipher->encrypt("plaintex"); # NB - 8 bytes print unpack("H16", $ciphertext), " "; NOTES
Do note that DES only uses 8 byte keys and only works on 8 byte data blocks. If you're intending to encrypt larger blocks or entire files, please use Crypt::CBC in conjunction with this module. See the Crypt::CBC documentation for proper syntax and use. Also note that the DES algorithm is, by today's standard, weak encryption. Crypt::Blowfish is highly recommended if you're interested in using strong encryption and a faster algorithm. SEE ALSO
Crypt::Blowfish Crypt::IDEA Bruce Schneier, Applied Cryptography, 1995, Second Edition, published by John Wiley & Sons, Inc. COPYRIGHT
The implementation of the DES algorithm was developed by, and is copyright of, Eric Young (eay@mincom.oz.au). Other parts of the perl extension and module are copyright of Systemics Ltd ( http://www.systemics.com/ ). Cross-platform work and packaging for single algorithm distribution is copyright of W3Works, LLC. MAINTAINER
This single-algorithm package and cross-platform code is maintained by Dave Paris <amused@pobox.com>. perl v5.12.1 2005-12-08 DES(3)
Man Page