承接 rych/random 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

rych/random

Composer 安装命令:

composer require rych/random

包简介

Random data generator for PHP

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

This library aims to provide a clean interface to generating cryptographically secure random data in PHP 5.3+.

Install

Via Composer

$ composer require rych/random

Usage

The library is easy to get up and running quickly. The best source of random data available for your platform will be automatically selected and configured.

<?php

$random = new Rych\Random\Random();

// Generate a 16-byte string of random raw data
$randomBytes = $random->getRandomBytes(16);

// Get a random integer between 1 and 100
$randomNumber = $random->getRandomInteger(1, 100);

// Get a random 8-character string using the
// character set A-Za-z0-9./
$randomString = $random->getRandomString(8);

If you prefer your random bytes delivered in hex format, we can do that too:

<?php

$encoder = new Rych\Random\Encoder\HexEncoder();
$random = new Rych\Random\Random();
$random->setEncoder($encoder);

// Generate a 16-byte string of random raw data,
// encoded as a 32-character hex string
$randomBytes = $random->getRandomBytes(16);

Generators

The library provides support for several CSPRNGs. The generator factory class Rych\Random\Generator\GeneratorFactory can be used to automatically discover and select the best available option for the current platform.

MCrypt (Rych\Random\Generator\MCryptGenerator)

MCrypt provides an interface to standard operating system CSPRNGs through the mcrypt_create_iv() function. On Windows systems, this function will use the Windows CryptoAPI, while other operating systems will read from /dev/urandom. This backend requires PHP's MCrypt extension to be enabled.

This is the preferred backend, and will be selected by default if it is available.

OpenSSL (Rych\Random\Generator\OpenSSLGenerator)

OpenSSL provides a CSPRNG through the openssl_random_pseudo_bytes() function. Support for this backend requires that PHP's OpenSSL extension be available. Windows servers also have the requirement of running PHP versions >= 5.3.7 due to a bug in the PHP OpenSSL implementation which could cause the function to perform slowly or even hang.

The OpenSSL backend is the second preferred backend, and will be selected if it is available.

CAPICOM (Rych\Random\Generator\CapicomGenerator)

Although Microsoft has deprecated the CAPICOM interface, the library currently supports the old interface. Support requires running on a Windows server with the COM extension enabled.

It should be noted that the MCrypt backend, if available, will use the newer Windows CryptoAPI to access Windows' built-in CSPRNG. The OpenSSL backend will do the same on PHP versions >= 5.4.0.

As CAPICOM is deprecated, it will only be selected if neither the MCrypt or OpenSSL backends are available on Windows systems.

/dev/urandom (Rych\Random\Generator\URandomGenerator)

The built-in non-blocking CSPRNG on most non-Windows platforms is supported by this backend. Support requires read-access to /dev/urandom on non-Windows platforms.

This backend will only be selected if neither the MCrypt or OpenSSL backends are available on non-Windows systems.

George Argyros' clock drift algorithm (Rych\Random\Generator\ClockDriftGenerator)

Systems which cannot use any of the above backends will use this one. It provides a CSPRNG in pure PHP, although it is pretty slow.

This backend has no special requirements, and is therefore always available.

Testing

$ vendor/bin/phpunit -c phpunit.dist.xml

Security

If you discover any security related issues, please email rchouinard@gmail.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

rych/random 适用场景与选型建议

rych/random 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 454.41k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2012 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cryptography」 「random」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rych/random 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rych/random 我们能提供哪些服务?
定制开发 / 二次开发

基于 rych/random 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 454.41k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 20
  • 依赖项目数: 11
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-11-01