定制 wikimedia/alea 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wikimedia/alea

最新稳定版本:1.0.0

Composer 安装命令:

composer require wikimedia/alea

包简介

PHP port of the (non-cryptographic) Alea pseudo-random number generator

关键字:

README 文档

README

alea.php is a port of the non-cryptographic Alea pseudo-random number generator to PHP.

Alea was designed to be very fast (in JavaScript) and to generate non-platform-dependent repeatable sets of random numbers (when supplied with matching seeds). Given portable seeds (strings or integers, for example), numbers generated by the JavaScript version of alea will exactly match those generated by this PHP port, and vice-versa.

Install

This package is available on Packagist:

$ composer require wikimedia/alea

Usage

use Wikimedia\Alea\Alea;

$prng = new Alea(); // add an optional seed parameter
$nextRandom = $prng->random(); // or ->uint32() or ->fract53()

We also have the ability to sync up two Alea PRNGs (even across platforms) via the importState and exportState methods.

$prng1 = new Alea(200);

$prng1->random();
$prng1->random();

$prng2 = Alea::createWithState( $prng1->exportState() );

assert( $prng1->random() === $prng2->random() );
assert( $prng1->random() === $prng2->random() );
assert( $prng1->random() === $prng2->random() );

Acknowledgements

The Alea code was written (in JavaScript) by Johannes Baagøe, and packaged for npm by coverslide.

Read more on Johannes' site.

The port to PHP was initially done by C. Scott Ananian and is (c) Copyright 2019-2021 Wikimedia Foundation.

Both the original alea codebase and this port are distributed under the MIT license; see LICENSE for more info.

统计信息

  • 总下载量: 430.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-11