.\"
.\" Modified 2003-04-04, aeb
.\"
-.TH ENCRYPT 3 2015-08-08 "" "Linux Programmer's Manual"
+.TH ENCRYPT 3 2018-04-30 "" "Linux Programmer's Manual"
.SH NAME
encrypt, setkey, encrypt_r, setkey_r \- encrypt 64-bit messages
.SH SYNOPSIS
+.nf
.BR "#define _XOPEN_SOURCE" " /* See feature_test_macros(7) */"
-.br
.B #include <unistd.h>
.PP
.BI "void encrypt(char " block "[64], int " edflag );
.BR "#define _XOPEN_SOURCE" " /* See feature_test_macros(7) */"
-.br
.B #include <stdlib.h>
.PP
.BI "void setkey(const char *" key );
.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
-.br
.B "#include <crypt.h>"
.PP
.BI "void setkey_r(const char *" key ", struct crypt_data *" data );
-.br
.BI "void encrypt_r(char *" block ", int " edflag \
", struct crypt_data *" data );
+.fi
.PP
Each of these requires linking with \fI\-lcrypt\fP.
.SH DESCRIPTION
int direction;
int initialized;
};
-.fi
+.EE
.in
.PP
Before calling
.B ENOSYS
The function is not provided.
(For example because of former USA export restrictions.)
+.SH VERSIONS
+Because they employ the DES block cipher,
+which is no longer considered secure,
+.BR crypt (),
+.BR crypt_r (),
+.BR setkey (),
+and
+.BR setkey_r ()
+were removed in glibc 2.28.
+Applications should switch to a modern cryptography library, such as
+.BR libgcrypt .
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.BR setkey_r ()
are GNU extensions.
.SH NOTES
+.SS Availability in glibc
+See
+.BR crypt (3).
+.SS Features in glibc
In glibc 2.2, these functions use the DES algorithm.
.SH EXAMPLE
-.nf
+.EX
#define _XOPEN_SOURCE
#include <stdio.h>
#include <stdlib.h>
}
setkey(key);
}
- printf("Before encrypting: %s\\n", orig);
+ printf("Before encrypting: %s\en", orig);
encrypt(buf, 0);
for (i = 0; i < 8; i++) {
- for (j = 0, txt[i] = \(aq\\0\(aq; j < 8; j++) {
+ for (j = 0, txt[i] = \(aq\e0\(aq; j < 8; j++) {
txt[i] |= buf[i * 8 + j] << j;
}
- txt[8] = \(aq\\0\(aq;
+ txt[8] = \(aq\e0\(aq;
}
- printf("After encrypting: %s\\n", txt);
+ printf("After encrypting: %s\en", txt);
encrypt(buf, 1);
for (i = 0; i < 8; i++) {
- for (j = 0, txt[i] = \(aq\\0\(aq; j < 8; j++) {
+ for (j = 0, txt[i] = \(aq\e0\(aq; j < 8; j++) {
txt[i] |= buf[i * 8 + j] << j;
}
- txt[8] = \(aq\\0\(aq;
+ txt[8] = \(aq\e0\(aq;
}
- printf("After decrypting: %s\\n", txt);
+ printf("After decrypting: %s\en", txt);
exit(EXIT_SUCCESS);
}
-.fi
+.EE
.SH SEE ALSO
.BR cbc_crypt (3),
.BR crypt (3),