Skip to content

Commit

Permalink
Sync random functions and crypt
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Oct 11, 2023
1 parent 8a2f288 commit e60091a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 32 deletions.
30 changes: 2 additions & 28 deletions reference/random/functions/mt-getrandmax.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 2166824858a40ea664c558f2930b63b8f4fd89c6 Maintainer: dallas Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: c174b16add554508aafdd40c5d3f2997099882b6 Maintainer: dallas Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.mt-getrandmax" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>mt_getrandmax</refname>
Expand Down Expand Up @@ -30,32 +30,6 @@
<parameter>max</parameter> 参数而不是放大结果的最大值(更少的随机)。
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example><title>计算一个随机浮点数</title>
<programlisting role="php">
<![CDATA[
<?php
function randomFloat($min = 0, $max = 1) {
return $min + mt_rand() / mt_getrandmax() * ($max - $min);
}
var_dump(randomFloat());
var_dump(randomFloat(2, 20));
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
float(0.91601131712832)
float(16.511210331931)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
Expand Down
3 changes: 1 addition & 2 deletions reference/random/functions/mt-rand.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 826073522514072830b63bee2b6135dc675ea45d Maintainer: HonestQiao Status: ready -->
<!-- EN-Revision: 0b6c76516a299395a3703e6df44f8ea4cb4549a8 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.mt-rand" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -149,7 +149,6 @@ echo mt_rand(5, 15), "\n";
<member><function>mt_getrandmax</function></member>
<member><function>random_int</function></member>
<member><function>random_bytes</function></member>
<member><function>rand</function></member>
</simplelist>
</para>
</refsect1>
Expand Down
4 changes: 2 additions & 2 deletions reference/strings/functions/crypt.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: cc88cbd3303ca3342dcdcd643eae793e564730c7 Maintainer: mowangjuanzi Status: ready -->
<!-- EN-Revision: 60b29fbe11384d5233398d70fdc74e9078fe32ad Maintainer: mowangjuanzi Status: ready -->
<!-- CREDITS: Luffy -->
<refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="function.crypt">
<refnamediv>
Expand Down Expand Up @@ -155,7 +155,7 @@
$user_input = 'rasmuslerdorf';
$hashed_password = '$6$rounds=1000000$NJy4rIPjpOaU$0ACEYGg/aKCY3v8O8AfyiO7CTfZQ8/W231Qfh2tRLmfdvFD6XfHk12u6hMr9cYIA4hnpjLNSTRtUwYr9km9Ij/';
// 验证现有的 crypt() 哈希值,以便与非 PHP 软件兼容
// 以与非 PHP 软件兼容的方式验证现有的 crypt() 哈希值。
if (hash_equals($hashed_password, crypt($user_input, $hashed_password))) {
echo "Password verified!";
}
Expand Down

0 comments on commit e60091a

Please sign in to comment.