芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/sommatv/vendor/ircmaxell/random-lib/lib/RandomLib/Source/CAPICOM.php
* @copyright 2011 The Authors * @license http://www.opensource.org/licenses/mit-license.html MIT License * @version Build @@version@@ */ /** * The Capicom Random Number Source * * This uses the Windows CapiCom Com object to generate random numbers * * PHP version 5.3 * * @category PHPCryptLib * @package Random * @subpackage Source * * @author Anthony Ferrara
* @copyright 2011 The Authors * @license http://www.opensource.org/licenses/mit-license.html MIT License * * @version Build @@version@@ */ namespace RandomLib\Source; use SecurityLib\Strength; /** * The Capicom Random Number Source * * This uses the Windows CapiCom Com object to generate random numbers * * @category PHPCryptLib * @package Random * @subpackage Source * * @author Anthony Ferrara
* @codeCoverageIgnore */ class CAPICOM extends \RandomLib\AbstractSource { /** * Return an instance of Strength indicating the strength of the source * * @return \SecurityLib\Strength An instance of one of the strength classes */ public static function getStrength() { return new Strength(Strength::MEDIUM); } /** * If the source is currently available. * Reasons might be because the library is not installed * * @return bool */ public static function isSupported() { return class_exists('\\COM', false); } /** * Generate a random string of the specified size * * @param int $size The size of the requested random string * * @return string A string of the requested size */ public function generate($size) { try { $util = new \COM('CAPICOM.Utilities.1'); $data = base64_decode($util->GetRandom($size, 0)); return str_pad($data, $size, chr(0)); } catch (\Exception $e) { unset($e); return static::emptyValue($size); } } }