ENCRYPT(3POSIX)
π ENCRYPT(3POSIX) β the POSIX Programmer's Manual one, bestie π
okay so before we even get into it: this page lives inside the POSIX Programmer's Manual, bestie. and like β huge heads up β the Linux implementation of this interface may differ (so go check the matching Linux man page for the actual Linux tea), or honestly the interface might just not be implemented on Linux at all. so keep that in mind before you start coding like it's guaranteed. π
β¨ PROLOG β¨
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β consult the corresponding Linux manual page for details of Linux behavior β or the interface may not be implemented on Linux.
πΈ NAME πΈ
encrypt β encoding function (CRYPT)
π SYNOPSIS π
#include <unistd.h>
void encrypt(char block[64], int edflag);
π DESCRIPTION π
So encrypt() shall give you access to an implementation-defined encoding algorithm. The key that setkey() generated? Yeah, that's the one encrypt() uses to encrypt the string block. iconic teamwork honestly. π₯
The block argument to encrypt() shall be an array of length 64 bytes, and it's gotta contain only the bytes with values of 0 and 1. that's it. no other values, bestie. The array gets modified in place into a similar array using the key that setkey() set. π«
Now for edflag, this is the part you actually need to pay attention to:
- If
edflagis0, the argument is encoded. - If
edflagis1, the argument may be decoded (peep the APPLICATION USAGE section for why that "may" is doing so much heavy lifting); and if the argument is not decoded,errnoshall be set to[ENOSYS].
encrypt() shall not change the setting of errno if it's successful. so if you're the type who wants to check for error situations, set errno to 0 before you call encrypt(). Then, if errno is non-zero on return? an error has occurred, periodt.
Also, encrypt() need not be thread-safe. just so you know. no cap. π
π RETURN VALUE π
encrypt() shall not return a value. that's it, that's the whole section. she's void, she's mysterious, she gives nothing back. π«Ά
π ERRORS π
encrypt() shall fail if:
ENOSYSβ The functionality is not supported on this implementation.
The following sections are informative. π (yes, that means the vibes shift from "rules" to "lore")
β EXAMPLES β
None.
like literally none. nothing. empty. the void. π³οΈ
π¦ APPLICATION USAGE π¦
Historical implementations of encrypt() used a rather primitive encoding algorithm. ngl, lowkey embarrassing for them. π
In some environments, decoding might not be implemented at all. And the reason is kind of wild: it's related to some Government restrictions on encryption and decryption routines. Historical practice has been to ship a different version of the encryption library without the decryption feature in the routines supplied. So the exported version of encrypt() does encoding but not decoding. iykyk. π
π RATIONALE π
None.
π FUTURE DIRECTIONS π
A future version of the standard may mark this interface as obsolete or remove it altogether. so likeβ¦ don't build your whole personality around it, bestie. π
π SEE ALSO π
crypt()setkey()
The Base Definitions volume of POSIX.1β2017, <unistd.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! this one's brought to you by IEEE/The Open Group, 2017, and it's the ENCRYPT(3POSIX) page β go forth and encrypt responsibly, mwah πβ¨π
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms