|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<!-- $Revision$ --> |
| 3 | +<!-- EN-Revision: 299488 Maintainer: masakielastic Status: ready --> |
| 4 | +<!-- Reviewed: no --> |
| 5 | + |
| 6 | +<refentry xml:id="function.hash-pbkdf2" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 7 | + <refnamediv> |
| 8 | + <refname>hash_pbkdf2</refname> |
| 9 | + <refpurpose>PBKDF2 を使ってパスワードからキーを生成する</refpurpose> |
| 10 | + </refnamediv> |
| 11 | + |
| 12 | + <refsect1 role="description"> |
| 13 | + &reftitle.description; |
| 14 | + <methodsynopsis role="procedural"> |
| 15 | + <type>string</type><methodname>hash_pbkdf2</methodname> |
| 16 | + <methodparam><type>string</type><parameter>algo</parameter></methodparam> |
| 17 | + <methodparam><type>string</type><parameter>password</parameter></methodparam> |
| 18 | + <methodparam><type>string</type><parameter>salt</parameter></methodparam> |
| 19 | + <methodparam><type>int</type><parameter>iterations</parameter></methodparam> |
| 20 | + <methodparam choice="opt"><type>int</type><parameter>length</parameter><initializer>0</initializer></methodparam> |
| 21 | + <methodparam choice="opt"><type>bool</type><parameter>raw_output</parameter><initializer>false</initializer></methodparam> |
| 22 | + </methodsynopsis> |
| 23 | + </refsect1> |
| 24 | + |
| 25 | + <refsect1 role="parameters"> |
| 26 | + &reftitle.parameters; |
| 27 | + <para> |
| 28 | + <variablelist> |
| 29 | + <varlistentry> |
| 30 | + <term><parameter>algo</parameter></term> |
| 31 | + <listitem> |
| 32 | + <para> |
| 33 | + ハッシュアルゴリズムの名前 (たとえば <literal>md5</literal>, |
| 34 | + <literal>sha256</literal>, <literal>haval160,4</literal> など)。サポートされるアルゴリズムの一覧は |
| 35 | + <function>hash_algos</function> をご参照ください。 |
| 36 | + </para> |
| 37 | + </listitem> |
| 38 | + </varlistentry> |
| 39 | + <varlistentry> |
| 40 | + <term><parameter>password</parameter></term> |
| 41 | + <listitem> |
| 42 | + <para> |
| 43 | + 派生に使うパスワード |
| 44 | + </para> |
| 45 | + </listitem> |
| 46 | + </varlistentry> |
| 47 | + <varlistentry> |
| 48 | + <term><parameter>salt</parameter></term> |
| 49 | + <listitem> |
| 50 | + <para> |
| 51 | + 派生に使うソルト |
| 52 | + </para> |
| 53 | + </listitem> |
| 54 | + </varlistentry> |
| 55 | + <varlistentry> |
| 56 | + <term><parameter>iterations</parameter></term> |
| 57 | + <listitem> |
| 58 | + <para> |
| 59 | + 派生の実行の際の内部の反復回数 |
| 60 | + </para> |
| 61 | + </listitem> |
| 62 | + </varlistentry> |
| 63 | + <varlistentry> |
| 64 | + <term><parameter>length</parameter></term> |
| 65 | + <listitem> |
| 66 | + <para> |
| 67 | + 出力する派生キーの長さ。<literal>0</literal> の場合、渡されたアルゴリズムの長さが使われます。 |
| 68 | + </para> |
| 69 | + </listitem> |
| 70 | + </varlistentry> |
| 71 | + <varlistentry> |
| 72 | + <term><parameter>raw_output</parameter></term> |
| 73 | + <listitem> |
| 74 | + <para> |
| 75 | + &true; にセットされている場合、名前のバイナリデータが出力されます。&false; の場合、小文字の16進数が出力されます。 |
| 76 | + </para> |
| 77 | + </listitem> |
| 78 | + </varlistentry> |
| 79 | + </variablelist> |
| 80 | + </para> |
| 81 | + </refsect1> |
| 82 | + |
| 83 | + <refsect1 role="returnvalues"><!-- {{{ --> |
| 84 | + &reftitle.returnvalues; |
| 85 | + <para> |
| 86 | + 小文字の16進数を含む文字列が返されます。<parameter>raw_output</parameter> が true の場合、派生キーの生のバイナリ表現が返されます。 |
| 87 | + </para> |
| 88 | + </refsect1><!-- }}} --> |
| 89 | + |
| 90 | + <refsect1 role="errors"><!-- {{{ --> |
| 91 | + &reftitle.errors; |
| 92 | + <para> |
| 93 | + <constant>E_WARNING</constant> が発生するのはアルゴリズムが未知である場合、<parameter>iterations</parameter> パラメータが <literal>0</literal> 以下である場合、<parameter>length</parameter> が <literal>0</literal> 以下である場合、<parameter>salt</parameter> が長すぎる場合 |
| 94 | + (<constant>INT_MAX</constant><literal> - 4</literal> よりも大きい) です。 |
| 95 | + </para> |
| 96 | + </refsect1><!-- }}} --> |
| 97 | + |
| 98 | + <refsect1 role="examples"> |
| 99 | + &reftitle.examples; |
| 100 | + <para> |
| 101 | + <example> |
| 102 | + <title><function>hash_pbkdf2</function> の基本的な使い方の例</title> |
| 103 | + <programlisting role="php"> |
| 104 | +<![CDATA[ |
| 105 | +<?php |
| 106 | +$password = "password"; |
| 107 | +$salt = "salt"; |
| 108 | +$hash = hash_pbkdf2("sha256", $password, $salt, 1, 20); |
| 109 | +echo $hash; |
| 110 | +?> |
| 111 | +]]> |
| 112 | + </programlisting> |
| 113 | + &example.outputs; |
| 114 | + <screen> |
| 115 | +<![CDATA[ |
| 116 | +120fb6cffcf8b32c43e7 |
| 117 | +]]> |
| 118 | + </screen> |
| 119 | + </example> |
| 120 | + </para> |
| 121 | + </refsect1> |
| 122 | + |
| 123 | + <refsect1 role="notes"> |
| 124 | + &reftitle.notes; |
| 125 | + <caution> |
| 126 | + <para> |
| 127 | + PBKDF2 による方法はパスワードのハッシュを保存するために使うことができます (NIST が認めた利用方法です)。 |
| 128 | + しかしながら、<constant>CRYPT_BLOWFISH</constant> のほうがパスワードの保存に適しており、<function>crypt</function> を通じて利用できることを記しておきます。 |
| 129 | + </para> |
| 130 | + </caution> |
| 131 | + </refsect1> |
| 132 | + |
| 133 | + <refsect1 role="seealso"> |
| 134 | + &reftitle.seealso; |
| 135 | + <para> |
| 136 | + <simplelist> |
| 137 | + <member><function>crypt</function></member> |
| 138 | + <member><function>hash</function></member> |
| 139 | + <member><function>hash_algos</function></member> |
| 140 | + <member><function>hash_init</function></member> |
| 141 | + <member><function>hash_hmac</function></member> |
| 142 | + <member><function>hash_hmac_file</function></member> |
| 143 | + </simplelist> |
| 144 | + </para> |
| 145 | + </refsect1> |
| 146 | + |
| 147 | +</refentry> |
| 148 | + |
| 149 | +<!-- Keep this comment at the end of the file |
| 150 | +Local variables: |
| 151 | +mode: sgml |
| 152 | +sgml-omittag:t |
| 153 | +sgml-shorttag:t |
| 154 | +sgml-minimize-attributes:nil |
| 155 | +sgml-always-quote-attributes:t |
| 156 | +sgml-indent-step:1 |
| 157 | +sgml-indent-data:t |
| 158 | +indent-tabs-mode:nil |
| 159 | +sgml-parent-document:nil |
| 160 | +sgml-default-dtd-file:"~/.phpdoc/manual.ced" |
| 161 | +sgml-exposed-tags:nil |
| 162 | +sgml-local-catalogs:nil |
| 163 | +sgml-local-ecat-files:nil |
| 164 | +End: |
| 165 | +vim600: syn=xml fen fdm=syntax fdl=2 si |
| 166 | +vim: et tw=78 syn=sgml |
| 167 | +vi: ts=1 sw=1 |
| 168 | +--> |
0 commit comments