⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crypt.html

📁 posix标准英文,html格式
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2004 IEEE and The Open Group, All Rights Reserved --><title>crypt</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="crypt"></a> <a name="tag_03_94"></a><!-- crypt --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2004 Edition<br>Copyright &copy; 2001-2004 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_94_01"></a>NAME</h4><blockquote>crypt - string encoding function (<b>CRYPT</b>)</blockquote><h4><a name="tag_03_94_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> #include &lt;<a href="../basedefs/unistd.h.html">unistd.h</a>&gt;<br><br> char *crypt(const char *</tt><i>key</i><tt>, const char *</tt><i>salt</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_03_94_03"></a>DESCRIPTION</h4><blockquote><p>The <i>crypt</i>() function is a string encoding function. The algorithm is implementation-defined.</p><p>The <i>key</i> argument points to a string to be encoded. The <i>salt</i> argument is a string chosen from the set:</p><pre><tt>a b c d e f g h i j k l m n o p q r s t u v w x y zA B C D E F G H I J K L M N O P Q R S T U V W X Y Z0 1 2 3 4 5 6 7 8 9 . /</tt></pre><p>The first two characters of this string may be used to perturb the encoding algorithm.</p><p>The return value of <i>crypt</i>() points to static data that is overwritten by each call.</p><p>The <i>crypt</i>() function need not be reentrant. A function that is not required to be reentrant is not required to bethread-safe.</p></blockquote><h4><a name="tag_03_94_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>crypt</i>() shall return a pointer to the encoded string. The first two characters of thereturned value shall be those of the <i>salt</i> argument. Otherwise, it shall return a null pointer and set <i>errno</i> toindicate the error.</p></blockquote><h4><a name="tag_03_94_05"></a>ERRORS</h4><blockquote><p>The <i>crypt</i>() function shall fail if:</p><dl compact><dt>[ENOSYS]</dt><dd>The functionality is not supported on this implementation.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_94_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_94_06_01"></a>Encoding Passwords</h5><p>The following example finds a user database entry matching a particular user name and changes the current password to a newpassword. The <i>crypt</i>() function generates an encoded version of each password. The first call to <i>crypt</i>() produces anencoded version of the old password; that encoded password is then compared to the password stored in the user database. The secondcall to <i>crypt</i>() encodes the new password before it is stored.</p><p>The <i>putpwent</i>() function, used in the following example, is not part of IEEE&nbsp;Std&nbsp;1003.1-2001.</p><pre><tt>#include &lt;unistd.h&gt;#include &lt;pwd.h&gt;#include &lt;string.h&gt;#include &lt;stdio.h&gt;...int valid_change;int pfd;  /* Integer for file descriptor returned by open(). */FILE *fpfd;  /* File pointer for use in putpwent(). */struct passwd *p;char user[100];char oldpasswd[100];char newpasswd[100];char savepasswd[100];...valid_change = 0;while ((p = getpwent()) != NULL) {    /* Change entry if found. */    if (strcmp(p-&gt;pw_name, user) == 0) {        if (strcmp(p-&gt;pw_passwd, crypt(oldpasswd, p-&gt;pw_passwd)) == 0) {            strcpy(savepasswd, crypt(newpasswd, user));            p-&gt;pw_passwd = savepasswd;            valid_change = 1;        }        else {            fprintf(stderr, "Old password is not valid\n");        }    }    /* Put passwd entry into ptmp. */    putpwent(p, fpfd);}</tt></pre></blockquote><h4><a name="tag_03_94_07"></a>APPLICATION USAGE</h4><blockquote><p>The values returned by this function need not be portable among XSI-conformant systems.</p></blockquote><h4><a name="tag_03_94_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_94_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_94_10"></a>SEE ALSO</h4><blockquote><p><a href="encrypt.html"><i>encrypt</i>()</a>, <a href="setkey.html"><i>setkey</i>()</a>, the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/unistd.h.html"><i>&lt;unistd.h&gt;</i></a></p></blockquote><h4><a name="tag_03_94_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 1. Derived from Issue 1 of the SVID.</p></blockquote><h4><a name="tag_03_94_12"></a>Issue 5</h4><blockquote><p>Normative text previously in the APPLICATION USAGE section is moved to the DESCRIPTION.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -