ejfrancis / php-random-value
安全随机值生成器。
dev-master
2017-06-02 23:21 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-25 11:33:52 UTC
README
PHPRandomValue 是一个 PHP 类,用于生成随机值,包括数字、文本字符串和键,最初是为使用在 AlpineAuth 库中而开发的。
使用 mcrypt_create_iv(4, MCRYPT_DEV_URANDOM) 生成随机数字。随机文本字符串和键(包括字母和字符)通过使用数字生成器随机选择字符来创建。
安装
推荐的安装方法是使用 composer,以下为 require 语句:
"ejfrancis/php-random-value": "dev-master"
您也可以下载类文件 RandomValue.php
并手动包含它。
示例用法和输出
include_once( 'RandomValue.php' ); $randomValue = new ejfrancis\RandomValue; $randomValue->randomNumber(): //-3880998 $randomValue->randomNumberBetween(1,10): //2 $randomValue->randomTextString(): //CfCkKDHRgUULdGWcSqP4 $randomValue->randomTextString(10): //LorPIxaeEY $randomValue->randomKey(): //C7al8tX9.gqYLf2ImVt/!$NOY79T5sNCT/6Q.$!.6Gf/Q5zpa3 $randomValue->randomKey(10): //RDV.dc6Ai/ $randomValue->randomStrongerKey(): //{I}s3897:}$xz4R@hpd!_+1L13[:_%1::pv/-asp2%4^#5$iG$F:{_Jf5s-98]raaqrhZ*Jg2k-nT-{9nBxsl!^dFI&21f"V:mU3 $randomValue->randomStrongerKey(15): //q:]qf941l[D&s8A