mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 22:06:57 +08:00
115 lines
3.6 KiB
HTML
115 lines
3.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Generates a key</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.mhash-keygen-s2k" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">mhash_keygen_s2k</h1>
|
|
<p class="verinfo">(PHP 4 >= 4.0.4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">mhash_keygen_s2k</span> — <span class="dc-title">Generates a key</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.mhash-keygen-s2k-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>mhash_keygen_s2k</strong></span>
|
|
( <span class="methodparam"><span class="type">int</span> <code class="parameter">$hash</code></span>
|
|
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$password</code></span>
|
|
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$salt</code></span>
|
|
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$bytes</code></span>
|
|
) : <span class="type">string</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Generates a key according to the given <code class="parameter">hash</code>, using an user
|
|
provided <code class="parameter">password</code>.
|
|
</p>
|
|
<p class="para">
|
|
This is the Salted S2K algorithm as specified in the OpenPGP
|
|
document (<a href="http://www.faqs.org/rfcs/rfc2440" class="link external">» RFC 2440</a>).
|
|
</p>
|
|
<p class="para">
|
|
Keep in mind that user supplied passwords are not really suitable
|
|
to be used as keys in cryptographic algorithms, since users normally
|
|
choose keys they can write on keyboard. These passwords use
|
|
only 6 to 7 bits per character (or less). It is highly recommended
|
|
to use some kind of transformation (like this function) to the user
|
|
supplied key.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.mhash-keygen-s2k-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">hash</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The hash ID used to create the key.
|
|
One of the <strong><code>MHASH_hashname</code></strong> constants.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">password</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
An user supplied password.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">salt</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
Must be different and random enough for every key you generate in
|
|
order to create different keys. Because <code class="parameter">salt</code>
|
|
must be known when you check the keys, it is a good idea to append
|
|
the key to it. Salt has a fixed length of 8 bytes and will be padded
|
|
with zeros if you supply less bytes.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">bytes</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The key length, in bytes.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.mhash-keygen-s2k-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns the generated key as a string, or <strong><code>FALSE</code></strong> on error.
|
|
</p>
|
|
</div>
|
|
|
|
</div></div></div></body></html> |