📄 crypt.3
字号:
.TH CRYPT 3.SH NAMEcrypt \- one-way password encryption function.SH SYNOPSIS.ft B.nf#define _MINIX_SOURCE 1#include <unistd.h>char *crypt(const char *\fIkey\fP, const char *\fIsalt\fP).fi.ft P.SH DESCRIPTIONThe first use of.B crypt()is to encrypt a password. Its second use is to authenticate a shadowpassword. In both cases.B crypt()calls.BR pwdauth (8)to do the real work..PP.B Crypt()encrypts a password if called with a user typed key, and a saltwhose first two characters are in the set [./0-9A-Za-z]. The result is acharacter string in the [./0-9A-Za-z] alphabet of which the first twocharacters are equal to the salt, and the rest is the result of encryptingthe key and the salt..PPIf.B crypt()is called with a salt that has the form.BI "##" userthen the key is encrypted and compared to the encrypted password of.I userin the shadow password file. If they are equal then.B crypt()returns the.BI "##" userargument, if not then some other string is returned. This trick assuresthat the normal way to authenticate a password still works:.PP.RS.nfif (strcmp(pw->pw_passwd, crypt(key, pw->pw_passwd))) ....fi.RE.PPIf.I keyis a null string, and the shadow password is a null string or the salt is anull string then the result equals.IR salt .(This is because the caller can't tell if a password field is empty in theshadow password file.).PPThe key and salt are limited to 1024 bytes total including the null bytes..SH FILES.TP 25/usr/lib/pwdauthThe password authentication program.SH "SEE ALSO".BR getpass (3),.BR getpwent (3),.BR passwd (5),.BR pwdauth (8)..SH NOTESThe result of an encryption is returned in a static array that isoverwritten by each call. The return value should not be modified..SH AUTHORKees J. Bot (kjb@cs.vu.nl)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -