reference/csprng/functions/random-bytes.xml
2166824858a40ea664c558f2930b63b8f4fd89c6
...
...
@@ -1,111 +0,0 @@
1
-
<?xml version="1.0" encoding="utf-8"?>
2
-
<!-- $Revision$ -->
3
-

4
-
<refentry xml:id="function.random-bytes" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
-
<refnamediv>
6
-
<refname>random_bytes</refname>
7
-
<refpurpose>Generates cryptographically secure pseudo-random bytes</refpurpose>
8
-
</refnamediv>
9
-

10
-
<refsect1 role="description"><!-- {{{ -->
11
-
&reftitle.description;
12
-
<methodsynopsis role="procedural">
13
-
<type>string</type><methodname>random_bytes</methodname>
14
-
<methodparam><type>int</type><parameter>length</parameter></methodparam>
15
-
</methodsynopsis>
16
-
<para>
17
-
Generates an arbitrary length string of cryptographic random bytes that are
18
-
suitable for cryptographic use, such as when generating salts, keys or
19
-
initialization vectors.
20
-
</para>
21
-
&csprng.sources;
22
-
&csprng.function.backport;
23
-
</refsect1><!-- }}} -->
24
-

25
-
<refsect1 role="parameters"><!-- {{{ -->
26
-
&reftitle.parameters;
27
-
<variablelist>
28
-
<varlistentry>
29
-
<term><parameter>length</parameter></term>
30
-
<listitem>
31
-
<para>
32
-
The length of the random string that should be returned in bytes.
33
-
</para>
34
-
</listitem>
35
-
</varlistentry>
36
-
</variablelist>
37
-
</refsect1><!-- }}} -->
38
-

39
-
<refsect1 role="returnvalues"><!-- {{{ -->
40
-
&reftitle.returnvalues;
41
-
<para>
42
-
Returns a string containing the requested number of cryptographically
43
-
secure random bytes.
44
-
</para>
45
-
</refsect1><!-- }}} -->
46
-

47
-
<refsect1 role="errors"><!-- {{{ -->
48
-
&reftitle.errors;
49
-
<itemizedlist>
50
-
&csprng.errors;
51
-
<listitem>
52
-
<simpara>
53
-
If an invalid <parameter>length</parameter> of bytes is given, an
54
-
<classname>Error</classname> will be thrown.
55
-
</simpara>
56
-
</listitem>
57
-
</itemizedlist>
58
-
</refsect1><!-- }}} -->
59
-

60
-
<refsect1 role="examples"><!-- {{{ -->
61
-
&reftitle.examples;
62
-
<example xml:id="random-bytes.example.basic"><!-- {{{ -->
63
-
<title><function>random_bytes</function> example</title>
64
-
<programlisting role="php">
65
-
<![CDATA[
66
-
<?php
67
-
$bytes = random_bytes(5);
68
-
var_dump(bin2hex($bytes));
69
-
?>
70
-
]]>
71
-
</programlisting>
72
-
&example.outputs.similar;
73
-
<screen>
74
-
<![CDATA[
75
-
string(10) "385e33f741"
76
-
]]>
77
-
</screen>
78
-
</example><!-- }}} -->
79
-
</refsect1><!-- }}} -->
80
-

81
-
<refsect1 role="seealso"><!-- {{{ -->
82
-
&reftitle.seealso;
83
-
<simplelist>
84
-
<member><function>random_int</function></member>
85
-
<member><function>openssl_random_pseudo_bytes</function></member>
86
-
<member><function>bin2hex</function></member>
87
-
</simplelist>
88
-
</refsect1><!-- }}} -->
89
-

90
-
</refentry>
91
-

92
-
<!-- Keep this comment at the end of the file
93
-
Local variables:
94
-
mode: sgml
95
-
sgml-omittag:t
96
-
sgml-shorttag:t
97
-
sgml-minimize-attributes:nil
98
-
sgml-always-quote-attributes:t
99
-
sgml-indent-step:1
100
-
sgml-indent-data:t
101
-
indent-tabs-mode:nil
102
-
sgml-parent-document:nil
103
-
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
104
-
sgml-exposed-tags:nil
105
-
sgml-local-catalogs:nil
106
-
sgml-local-ecat-files:nil
107
-
End:
108
-
vim600: syn=xml fen fdm=syntax fdl=2 si
109
-
vim: et tw=78 syn=sgml
110
-
vi: ts=1 sw=1
111
-
-->
112
0