<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Mhash - Funções de hash</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="Memcache::setServerParams" HREF="function.memcache-setserverparams.html"><LINK REL="NEXT" TITLE="mhash_count" HREF="function.mhash-count.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.memcache-setserverparams.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.mhash-count.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.mhash" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >LXXXVII. Mhash - Funções de hash</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN115142" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mhash.intro" >Introdução</A ></H1 ><P > Essas funções são planejadas para trabalhar com <A HREF="http://mhash.sourceforge.net/" TARGET="_top" >mhash</A >. Com o Mhash você pode criar checksums, digests de mensagens, códigos de autenticação de mensagens e mais. </P ><P > Esta é uma interface para a biblioteca mhash. O mhash suporta uma grande variedade de algoritmos de hash como MD5, SHA1, GOST e muitos outros. Para uma lista completa das hashs suportadas, verifique a documentação do mhash. A regra geral é: você pode acessar o algoritmo de hash a partir do PHP com MHASH_NOMEdoHASH, Por exemplo, para acessar o algoritmo TIGER, você utiliza a constante MHASH_TIGER. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mhash.requirements" >Dependências</A ></H1 ><P > Para usá-las, faça o download da distribuição do mhash em <A HREF="http://mhash.sourceforge.net/" TARGET="_top" >http://mhash.sourceforge.net/</A > e siga as instruções de instalação inclusas. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mhash.installation" >Instalação</A ></H1 ><P > You need to compile PHP with the <CODE CLASS="option" >--with-mhash[=DIR]</CODE > parameter to enable this extension. DIR is the mhash install directory. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mhash.configuration" >Configurações em execução</A ></H1 ><P >Esta extensão não define nenhum parâmetro de configuração no <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mhash.resources" >Tipos Resource</A ></H1 ><P >Esta extensão não possui nenhum tipo resource.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mhash.constants" >Constantes pré-definidas</A ></H1 ><P > As contantes abaixo são definidas por esta extensão e somente estarão disponíveis quando a extensão foi compilada com o PHP ou carregada dinamicamente durante a execução. </P ><P > Aqui está a lista de hashes que são atualmente suportadas por mhash. Se uma hash não está listada aqui, mas é listada pelo mhash como suportada, você pode assumir seguramente que esta documentação está desatualizada. <P ></P ><UL ><LI ><P > <TT CLASS="constant" ><B >MHASH_MD5</B ></TT > </P ></LI ><LI ><P > <TT CLASS="constant" ><B >MHASH_SHA1</B ></TT > </P ></LI ><LI ><P > <TT CLASS="constant" ><B >MHASH_HAVAL256</B ></TT > </P ></LI ><LI ><P > <TT CLASS="constant" ><B >MHASH_HAVAL192</B ></TT > </P ></LI ><LI ><P > <TT CLASS="constant" ><B >MHASH_HAVAL160</B ></TT > </P ></LI ><LI ><P > <TT CLASS="constant" ><B >MHASH_HAVAL128</B ></TT > </P ></LI ><LI ><P > <TT CLASS="constant" ><B >MHASH_RIPEMD160</B ></TT > </P ></LI ><LI ><P > <TT CLASS="constant" ><B >MHASH_GOST</B ></TT > </P ></LI ><LI ><P > <TT CLASS="constant" ><B >MHASH_TIGER</B ></TT > </P ></LI ><LI ><P > <TT CLASS="constant" ><B >MHASH_CRC32</B ></TT > </P ></LI ><LI ><P > <TT CLASS="constant" ><B >MHASH_CRC32B</B ></TT > </P ></LI ></UL > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mhash.examples" >Exemplos</A ></H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN115204" ></A ><P ><B >Exemplo 1. Calcular o MD5 digest e hmac e imprimir como hex</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />$input </font><font color="#007700">= </font><font color="#DD0000">"what do ya want for nothing?"</font><font color="#007700">;<br /></font><font color="#0000BB">$hash </font><font color="#007700">= </font><font color="#0000BB">mhash </font><font color="#007700">(</font><font color="#0000BB">MHASH_MD5</font><font color="#007700">, </font><font color="#0000BB">$input</font><font color="#007700">);<br />print </font><font color="#DD0000">"A hash é "</font><font color="#007700">.</font><font color="#0000BB">bin2hex </font><font color="#007700">(</font><font color="#0000BB">$hash</font><font color="#007700">).</font><font color="#DD0000">"<br />\n"</font><font color="#007700">;<br /></font><font color="#0000BB">$hash </font><font color="#007700">= </font><font color="#0000BB">mhash </font><font color="#007700">(</font><font color="#0000BB">MHASH_MD5</font><font color="#007700">, </font><font color="#0000BB">$input</font><font color="#007700">, </font><font color="#DD0000">"Jefe"</font><font color="#007700">);<br />print </font><font color="#DD0000">"A hmac é "</font><font color="#007700">.</font><font color="#0000BB">bin2hex </font><font color="#007700">(</font><font color="#0000BB">$hash</font><font color="#007700">).</font><font color="#DD0000">"<br />\n"</font><font color="#007700">;<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P > Este código irá produzir: <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >A hash é d03cb659cbf9192dcd066272249f8412 A hmac é 750c783e6ab0b503eaa86e310a5db738</PRE ></TD ></TR ></TABLE > </P ></DIV ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.mhash-count.html" >mhash_count</A > -- Ler o mais alto hash id disponível</DT ><DT ><A HREF="function.mhash-get-block-size.html" >mhash_get_block_size</A > -- Ler o tamanho do bloco da hash específicada</DT ><DT ><A HREF="function.mhash-get-hash-name.html" >mhash_get_hash_name</A > -- Ler o nome da hash especificada</DT ><DT ><A HREF="function.mhash-keygen-s2k.html" >mhash_keygen_s2k</A > -- Gerar uma chave</DT ><DT ><A HREF="function.mhash.html" >mhash</A > -- Computar a hash</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.memcache-setserverparams.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.mhash-count.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Memcache::setServerParams</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >mhash_count</TD ></TR ></TABLE ></DIV ></BODY ></HTML >