- Add an example to crypt() showing the usage of the various encryption

types.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@165294 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Dave Barr 2004-08-04 16:43:12 +00:00
parent b54e1771fb
commit fb667296aa

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.crypt">
<refnamediv>
@ -75,7 +75,7 @@
<listitem>
<simpara>
CRYPT_BLOWFISH - Blowfish encryption with a sixteen character salt
starting with $2$
starting with $2$ or $2a$
</simpara>
</listitem>
</itemizedlist>
@ -121,6 +121,37 @@ $hash = crypt($password, substr($password, 0, 2));
]]>
</programlisting>
</example>
<example>
<title>Using <function>crypt</function> with different encryption types</title>
<programlisting role="php">
<![CDATA[
<?php
if (CRYPT_STD_DES == 1)
echo 'Standard DES: ' . crypt('rasmuslerdorf', 'rl') . "\n";
if (CRYPT_EXT_DES == 1)
echo 'Extended DES: ' . crypt('rasmuslerdorf', '_J9..rasm') . "\n";
if (CRYPT_MD5 == 1)
echo 'MD5: ' . crypt('rasmuslerdorf', '$1$rasmusle$') . "\n";
if (CRYPT_BLOWFISH == 1)
echo 'Blowfish: ' . crypt('rasmuslerdorf', '$2a$07$rasmuslerd...........$') . "\n";
?>
]]>
</programlisting>
<para>
The above example will output something similar to:
</para>
<screen>
<![CDATA[
Standard DES: rl.3StKT.4T8M
Extended DES: _J9..rasmBYk8r9AiWNc
MD5: $1$rasmusle$rISCgZzpwk3UhDidwXvin0
Blowfish: $2a$07$rasmuslerd............nIdrcHdxcUxWomQX9j6kvERCFjTg7Ra
]]>
</screen>
</example>
<simpara>
See also <function>md5</function> and <link linkend="ref.mcrypt">the
Mcrypt extension</link>.