reference/openssl/functions/openssl-pbkdf2.xml
4c2ea3d32c3b66550abc4ef6d6dfc7753c01e22f
...
...
@@ -1,6 +1,5 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<refentry xml:id="function.openssl-pbkdf2" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
<refnamediv>
6
5
<refname>openssl_pbkdf2</refname>
...
...
@@ -10,12 +9,12 @@
10
9
<refsect1 role="description">
11
10
&reftitle.description;
12
11
<methodsynopsis>
13
-
<type>string</type><methodname>openssl_pbkdf2</methodname>
12
+
<type class="union"><type>string</type><type>false</type></type><methodname>openssl_pbkdf2</methodname>
14
13
<methodparam><type>string</type><parameter>password</parameter></methodparam>
15
14
<methodparam><type>string</type><parameter>salt</parameter></methodparam>
16
15
<methodparam><type>int</type><parameter>key_length</parameter></methodparam>
17
16
<methodparam><type>int</type><parameter>iterations</parameter></methodparam>
18
-
<methodparam choice="opt"><type>string</type><parameter>digest_algorithm</parameter><initializer>"sha1"</initializer></methodparam>
17
+
<methodparam choice="opt"><type>string</type><parameter>digest_algo</parameter><initializer>"sha1"</initializer></methodparam>
19
18
</methodsynopsis>
20
19
<para>
21
20
<function>openssl_pbkdf2</function> computes PBKDF2 (Password-Based Key Derivation Function 2),
...
...
@@ -62,7 +61,7 @@
62
61
</listitem>
63
62
</varlistentry>
64
63
<varlistentry>
65
-
<term><parameter>digest_algorithm</parameter></term>
64
+
<term><parameter>digest_algo</parameter></term>
66
65
<listitem>
67
66
<para>
68
67
Optional hash or digest algorithm from <function>openssl_get_md_methods</function>. Defaults to SHA-1.
...
...
@@ -87,10 +86,10 @@
87
86
<programlisting role="php">
88
87
<![CDATA[
89
88
<?php
90
-
$password = 'yOuR-pAs5w0rd-hERe';
91
-
$salt = openssl_random_pseudo_bytes(12);
92
-
$keyLength = 40;
93
-
$iterations = 10000;
89
+
$password = 'password';
90
+
$salt = openssl_random_pseudo_bytes(16);
91
+
$keyLength = 20;
92
+
$iterations = 600000;
94
93
$generated_key = openssl_pbkdf2($password, $salt, $keyLength, $iterations, 'sha256');
95
94
echo bin2hex($generated_key)."\n";
96
95
echo base64_encode($generated_key)."\n";
...
...
@@ -113,7 +112,6 @@ echo base64_encode($generated_key)."\n";
113
112
</refsect1>
114
113

115
114
</refentry>
116
-

117
115
<!-- Keep this comment at the end of the file
118
116
Local variables:
119
117
mode: sgml
120
118