php-doc-en/reference/hash/functions/hash-hmac.xml
2014-03-12 23:25:43 +00:00

125 lines
3.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.hash-hmac" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>hash_hmac</refname>
<refpurpose>Generate a keyed hash value using the HMAC method</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>hash_hmac</methodname>
<methodparam><type>string</type><parameter>algo</parameter></methodparam>
<methodparam><type>string</type><parameter>data</parameter></methodparam>
<methodparam><type>string</type><parameter>key</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>raw_output</parameter><initializer>false</initializer></methodparam>
</methodsynopsis>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>algo</parameter></term>
<listitem>
<para>
Name of selected hashing algorithm (i.e. "md5", "sha256", "haval160,4", etc..) See <function>hash_algos</function> for a list of supported algorithms.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>data</parameter></term>
<listitem>
<para>
Message to be hashed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>key</parameter></term>
<listitem>
<para>
Shared secret key used for generating the HMAC variant of the message digest.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>raw_output</parameter></term>
<listitem>
<para>
When set to &true;, outputs raw binary data.
&false; outputs lowercase hexits.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a string containing the calculated message digest as lowercase hexits
unless <parameter>raw_output</parameter> is set to true in which case the raw
binary representation of the message digest is returned.
Returns &false; when <parameter>algo</parameter> is unknown.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>hash_hmac</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
echo hash_hmac('ripemd160', 'The quick brown fox jumped over the lazy dog.', 'secret');
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
b8e7ae12510bdfb1812e463a7f086122cf37e4f7
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>hash</function></member>
<member><function>hash_algos</function></member>
<member><function>hash_init</function></member>
<member><function>hash_hmac_file</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
-->