久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

mt_rand 的缺點是什么?

What#39;s the disadvantage of mt_rand?(mt_rand 的缺點是什么?)
本文介紹了mt_rand 的缺點是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

偏見的定義是什么:

mt_rand() 返回值的分布在 64 位上偏向偶數當 max 超過 2^32 時構建 PHP.

The distribution of mt_rand() return values is biased towards even numbers on 64-bit builds of PHP when max is beyond 2^32.

如果這是四舍五入的替代平局規則中所述的那種偏見,我不'不要認為這真的很重要(因為偏差并不明顯).

If it's the kind of bias stated in alternate tie-breaking rules for rounding, I don't think it really matters (since the bias is not really visible).

除了 mt_rand() 被聲稱是四次比rand()快,只需在前面加三個字符即可!

Besides mt_rand() is claimed to be four times faster than rand(), just by adding three chars in front!

假設 mt_rand 可用,使用它的缺點是什么?

Assuming mt_rand is available, what's the disadvantage of using it?

推薦答案

mt_rand 使用 Mersenne Twister 算法,遠優于 LCGLCG代碼>rand.例如,LCG 的周期是微不足道的 232,而 mt_rand 的周期是 219937 ? 1.此外,LCG 生成的所有值將 躺在線上或平面繪制到多維空間中時.此外,確定LCG的參數不僅在實踐中可行,而且相對容易.LCG 的唯一優勢是速度可能稍快一些,但其規模與在 php 中編碼時完全無關.

mt_rand uses the Mersenne Twister algorithm, which is far better than the LCG typically used by rand. For example, the period of an LCG is a measly 232, whereas the period of mt_rand is 219937 ? 1. Also, all the values generated by an LCG will lie on lines or planes when plotted into a multidimensional space. Also, it is not only practically feasible, but relatively easy to determine the parameters of an LCG. The only advantage LCGs have is being potentially slightly faster, but on a scale that is completely irrelevant when coding in php.

但是,mt_rand不適合用于加密目的(生成令牌、密碼或加密密鑰).

However, mt_rand is not suitable for cryptographic purposes (generation of tokens, passwords or cryptographic keys) either.

如果您需要加密隨機性,請在 php 7 中使用 random_int.在較舊的 php 上版本,在符合 POSIX 的操作系統上從 /dev/urandom/dev/random 讀取.

If you need cryptographic randomness, use random_int in php 7. On older php versions, read from /dev/urandom or /dev/random on a POSIX-conforming operating system.

這篇關于mt_rand 的缺點是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Action View Helper in Zend - Work around?(Zend 中的動作視圖助手 - 解決方法?)
Is this a good way to match URI to class/method in PHP for MVC(這是將 URI 與 PHP 中用于 MVC 的類/方法匹配的好方法嗎)
Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(視圖),以便我的應用程序中的所有視圖都可以訪問?) - IT屋-程序員軟件開發技術
Having a single entry point to a website. Bad? Good? Non-issue?(有一個網站的單一入口點.壞的?好的?沒問題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務層在 Zend 或 PHP 中常見嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
主站蜘蛛池模板: 一本久久a久久精品亚洲 | 欧美群妇大交群中文字幕 | 国产亚洲欧美另类一区二区三区 | 亚洲精品乱码久久久久久久久久 | 欧美综合在线观看 | 国产精品久久欧美久久一区 | 91精品国产综合久久久亚洲 | 久久i| 久久噜噜噜精品国产亚洲综合 | 日日夜夜免费精品 | 日韩精品成人 | 久久精品亚洲一区二区三区浴池 | 日韩在线一区二区三区 | 成人在线免费视频观看 | 日韩高清中文字幕 | 日本一区二区电影 | 91久久精品国产免费一区 | 一区二区三区不卡视频 | 久久久久久综合 | 国产激情一区二区三区 | 国产一区高清 | 黄视频在线网站 | 欧美日韩精品中文字幕 | 精品国产乱码久久久久久蜜退臀 | 久久久久国产精品 | 91精品一区二区三区久久久久 | 国产传媒视频在线观看 | 日本一区二区在线视频 | 99re视频| 久久久www成人免费无遮挡大片 | 色站综合 | 亚洲小说图片 | 成人性视频免费网站 | 欧美爱爱视频 | 欧美1区2区 | 色婷婷一区二区三区四区 | 亚洲激精日韩激精欧美精品 | 欧美性精品| 青娱乐av | 久久久久亚洲 | 在线亚洲一区二区 |