mirror of
https://github.com/php/doc-ja.git
synced 2026-03-28 00:52:12 +01:00
* Document PHP 8.4 ext-hash changes を取り込み
E_DEPRECATEDを発生させるコード例
hash_init('murmur3f', 0, "", ["seed" => "10"]);// E_DEPRECATED
hash_init('murmur3f', 0, "", ["seed" => 10]);// OK
* `E_DEPRECATED` の説明を日本語の言い回しを優先し訳を崩す
---------
Co-authored-by: 武田 憲太郎 <takeda@youmind.jp>
220 lines
7.0 KiB
XML
220 lines
7.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: fe4ff341037cab316f76ca414f9a1a8ecdc4abfd Maintainer: takagi Status: ready -->
|
|
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
|
|
<!-- Credits: mumumu -->
|
|
<refentry xml:id="function.hash-init" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>hash_init</refname>
|
|
<refpurpose>段階的なハッシュコンテキストを初期化する</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>HashContext</type><methodname>hash_init</methodname>
|
|
<methodparam><type>string</type><parameter>algo</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
|
|
<methodparam choice="opt"><modifier role="attribute">#[\SensitiveParameter]</modifier><type>string</type><parameter>key</parameter><initializer>""</initializer></methodparam>
|
|
<methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam>
|
|
</methodsynopsis>
|
|
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>algo</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
選択したアルゴリズムの名前 (例: <literal>"sha256"</literal>)。
|
|
サポートされているアルゴリズムの一覧については、<function>hash_algos</function> を参照ください。
|
|
<note>
|
|
<para>
|
|
<constant>HASH_HMAC</constant> フラグが指定されている場合、
|
|
暗号に適さないハッシュ関数は許可されません。
|
|
</para>
|
|
</note>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
ハッシュ生成の際に使用するオプションで、現在は、ただひとつ
|
|
<constant>HASH_HMAC</constant> のみをサポートしています。これが
|
|
指定された場合、<parameter>key</parameter> を
|
|
<emphasis>必ず</emphasis>指定しなければなりません。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>key</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>flags</parameter> に <constant>HASH_HMAC</constant>
|
|
が指定された場合に、HMAC 形式のハッシュで使用される共有の秘密鍵を
|
|
設定する必要があります。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>options</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
様々なハッシュアルゴリズム向けの、オプションの配列。
|
|
現状は、MurmurHash バリアントが <literal>"seed"</literal>
|
|
だけをサポートしています。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
<function>hash_update</function>、
|
|
<function>hash_update_stream</function>、<function>hash_update_file</function>
|
|
および <function>hash_final</function> で使用するハッシュコンテキストを
|
|
返します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
<parameter>algo</parameter> が不明な場合や、
|
|
暗号に適さないハッシュ関数の場合、
|
|
または <parameter>key</parameter> が空の場合に
|
|
<classname>ValueError</classname> がスローされます。
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<parameter>options</parameter> に渡す設定値に型の誤りがあった場合
|
|
<constant>E_DEPRECATED</constant> が発生するようになりました。
|
|
予期しない解釈が行われる可能性があるためです。
|
|
これは将来 <exceptionname>ValueError</exceptionname> になる予定です。
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.4.0</entry>
|
|
<entry>誤った型のオプションを渡すことは非推奨となりました。</entry>
|
|
</row>
|
|
<row>
|
|
<entry>8.1.0</entry>
|
|
<entry><parameter>options</parameter> パラメータが追加されました。</entry>
|
|
</row>
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
<parameter>algo</parameter> が不明な場合や、
|
|
暗号に適さないハッシュ関数の場合、
|
|
または <parameter>key</parameter> が空の場合に
|
|
<classname>ValueError</classname> がスローされるようになりました。
|
|
これより前のバージョンでは、&false; を返し、
|
|
<constant>E_WARNING</constant> が発生していました。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>7.2.0</entry>
|
|
<entry>暗号に適さないハッシュ関数 (adler32, crc32, crc32b, fnv132, fnv1a32, fnv164, fnv1a64, joaat) は使えなくなりました。</entry>
|
|
</row>
|
|
<row>
|
|
<entry>7.2.0</entry>
|
|
<entry>
|
|
リソースの代わりに <classname>HashContext</classname> を返すようになりました。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>段階的なハッシュの例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$hash = hash('sha256', 'The quick brown fox jumped over the lazy dog.');
|
|
|
|
$ctx = hash_init('sha256');
|
|
hash_update($ctx, 'The quick brown fox ');
|
|
hash_update($ctx, 'jumped over the lazy dog.');
|
|
$incremental_hash = hash_final($ctx);
|
|
|
|
echo $incremental_hash, PHP_EOL;
|
|
var_dump($hash === $incremental_hash);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
|
|
bool(true)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>hash_algos</function></member>
|
|
<member><function>hash_update</function></member>
|
|
<member><function>hash_update_file</function></member>
|
|
<member><function>hash_update_stream</function></member>
|
|
<member><function>hash_final</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|