当前位置: 首页>>代码示例>>PHP>>正文


PHP Factory::getLowStrengthGenerator方法代码示例

本文整理汇总了PHP中RandomLib\Factory::getLowStrengthGenerator方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getLowStrengthGenerator方法的具体用法?PHP Factory::getLowStrengthGenerator怎么用?PHP Factory::getLowStrengthGenerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RandomLib\Factory的用法示例。


在下文中一共展示了Factory::getLowStrengthGenerator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getGenerator

 public function getGenerator($strength)
 {
     switch ($strength) {
         case 'low':
             return $this->factory->getLowStrengthGenerator();
         case 'medium':
             return $this->factory->getMediumStrengthGenerator();
         case 'high':
             throw new \InvalidArgumentException('"high" strength is currently unavailable');
         default:
             throw new \InvalidArgumentException('Could not find a generator for the specified strength');
     }
 }
开发者ID:zittix,项目名称:StringGeneratorBundle,代码行数:13,代码来源:SecureStringGenerator.php

示例2: generateOneTimeToken

 /**
  * Create a one time token
  *
  * Generates a low strength random number of size $bytes and hash with the
  * algorithm specified in $hash.
  *
  * @param string  $hash  hash function to use
  * @param integer $bytes the number of random bit to generate
  *
  * @return string hashed token
  */
 public static function generateOneTimeToken($hash = 'sha512', $bytes = 64)
 {
     $factory = new Factory();
     $generator = $factory->getLowStrengthGenerator();
     $token = hash($hash, $generator->generate($bytes));
     return $token;
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:18,代码来源:Random.php

示例3: migrateSettingsFile

 public static function migrateSettingsFile(Event $event = null)
 {
     if ($event !== null) {
         $event->getIO()->write("Migrating old setting file...");
     }
     if ($event) {
         $root_dir = realpath('');
     } else {
         $root_dir = realpath('../../');
     }
     if (file_exists($root_dir . '/app/config/parameters.yml')) {
         return false;
     }
     if (file_exists($root_dir . '/' . self::SETTINGS_FILE)) {
         $tmp_settings = file_get_contents($root_dir . '/' . self::SETTINGS_FILE);
         if (strpos($tmp_settings, '_DB_SERVER_') !== false) {
             $tmp_settings = preg_replace('/(\'|")\\_/', '$1_LEGACY_', $tmp_settings);
             file_put_contents($root_dir . '/' . self::SETTINGS_FILE, $tmp_settings);
             include $root_dir . '/' . self::SETTINGS_FILE;
             $factory = new RandomLib\Factory();
             $generator = $factory->getLowStrengthGenerator();
             $secret = $generator->generateString(56);
             $default_parameters = Yaml::parse($root_dir . '/app/config/parameters.yml.dist');
             $parameters = array('parameters' => array('database_host' => _LEGACY_DB_SERVER_, 'database_port' => '~', 'database_user' => _LEGACY_DB_USER_, 'database_password' => _LEGACY_DB_PASSWD_, 'database_name' => _LEGACY_DB_NAME_, 'database_prefix' => _LEGACY_DB_PREFIX_, 'database_engine' => _LEGACY_MYSQL_ENGINE_, 'cookie_key' => _LEGACY_COOKIE_KEY_, 'cookie_iv' => _LEGACY_COOKIE_IV_, 'ps_caching' => _LEGACY_PS_CACHING_SYSTEM_, 'ps_cache_enable' => _LEGACY_PS_CACHE_ENABLED_, 'ps_creation_date' => _LEGACY_PS_CREATION_DATE_, 'secret' => $secret, 'mailer_transport' => 'smtp', 'mailer_host' => '127.0.0.1', 'mailer_user' => '~', 'mailer_password' => '~') + $default_parameters['parameters']);
             if (file_put_contents($root_dir . '/app/config/parameters.yml', Yaml::dump($parameters))) {
                 $settings_content = "<?php\n";
                 $settings_content .= "//@deprecated 1.7";
                 file_put_contents($root_dir . '/' . self::SETTINGS_FILE, $settings_content);
             }
         }
     }
     if ($event !== null) {
         $event->getIO()->write("Finished...");
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:35,代码来源:Migrate.php

示例4: createCode

 /**
  * @return string
  */
 public function createCode()
 {
     $factory = new RandomLibFactory();
     $generator = $factory->getLowStrengthGenerator();
     $randomString = $generator->generateString($this->confirmationCodeLength, $this->confirmationCodeCharacters);
     return $randomString;
 }
开发者ID:basilicom,项目名称:pimcore-plugin-participation,代码行数:10,代码来源:Confirmation.php

示例5: let

 function let(Factory $factory, Generator $low, Generator $medium)
 {
     $factory->getMediumStrengthGenerator()->willReturn($medium);
     $factory->getLowStrengthGenerator()->willReturn($low);
     $this->beConstructedWith($factory);
     $defaults = ['length' => 32, 'chars' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'strength' => 'medium'];
     $this->setOptions($defaults);
 }
开发者ID:zittix,项目名称:StringGeneratorBundle,代码行数:8,代码来源:SecureStringGeneratorSpec.php

示例6: getLargeMessage

 /**
  * @return string
  */
 public function getLargeMessage()
 {
     if (!$this->largeMessage) {
         $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5(__METHOD__);
         if (file_exists($filename)) {
             // TODO Check file content length.
             return file_get_contents($filename);
         }
         $factory = new Factory();
         $generator = $factory->getLowStrengthGenerator();
         $this->largeMessage = $generator->generateString($this->largeMessageLength);
         file_put_contents($filename, $this->largeMessage);
     }
     return $this->largeMessage;
 }
开发者ID:abacaphiliac,项目名称:aws-sdk-php-claim-check,代码行数:18,代码来源:S3DataStoreContext.php

示例7: getLowStrengthGenerator

 /**
  * Convenience method to get a low strength random number generator.
  *
  * Low Strength should be used anywhere that random strings are needed
  * in a non-cryptographical setting. They are not strong enough to be
  * used as keys or salts. They are however useful for one-time use tokens.
  *
  * @return $this
  */
 public function getLowStrengthGenerator()
 {
     $this->generator = $this->factory->getLowStrengthGenerator();
     return $this;
 }
开发者ID:DaubaKao,项目名称:owncloud-core,代码行数:14,代码来源:securerandom.php

示例8: provideValidationData

 public function provideValidationData()
 {
     $factory = new Factory();
     $generator = $factory->getLowStrengthGenerator();
     return [[$generator->generateString(8), true], [$generator->generateString(8), false]];
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:6,代码来源:PasswordTokenValidatorTest.php

示例9: passwordProvider

 public function passwordProvider()
 {
     $factory = new Factory();
     $generator = $factory->getLowStrengthGenerator();
     return [[$generator->generateString(8), 'password', 'not_identical_password']];
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:6,代码来源:AccountTest.php

示例10: generateEmail

 /**
  * Generate a new valid email adress
  * @return string
  */
 private function generateEmail()
 {
     $factory = new Factory();
     $generator = $factory->getLowStrengthGenerator();
     return $generator->generateString(8, TokenManipulator::LETTERS_AND_NUMBERS) . '_email@email.com';
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:10,代码来源:LoginTest.php

示例11: uniqid

 public function uniqid($prefix)
 {
     $random = $this->randomLib->getLowStrengthGenerator();
     $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
     return $prefix . $random->generateString(12, $characters);
 }
开发者ID:pboethig,项目名称:puphpet,代码行数:6,代码来源:BaseExtension.php

示例12: randomInt

 /**
  * @param int $min
  * @param int $max
  *
  * @return int
  *
  * @codeCoverageIgnore
  */
 public static function randomInt($min = 0, $max = PHP_INT_MAX)
 {
     $factory = new Factory();
     $generator = $factory->getLowStrengthGenerator();
     $num = $generator->generateInt($min, $max);
     unset($factory);
     unset($generator);
     return $num;
 }
开发者ID:vuchl,项目名称:PHPhysics,代码行数:17,代码来源:MathProvider.php

示例13: uniqid

 public function uniqid()
 {
     $random = $this->randomLib->getLowStrengthGenerator();
     $characters = '0123456789abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
     return $random->generateString(12, $characters);
 }
开发者ID:freedog96150,项目名称:puphpet,代码行数:6,代码来源:BaseExtension.php

示例14: create

 public static function create()
 {
     $factory = new Factory();
     return new NonceProvider($factory->getLowStrengthGenerator());
 }
开发者ID:nightkidz,项目名称:tunai-whmcs,代码行数:5,代码来源:DefaultNonceProviderFactory.php

示例15: __construct

 /**
  * Constructor.
  *
  * @param ConnectionOptions $options Connection options object.
  */
 public function __construct(ConnectionOptions $options = null)
 {
     $this->pings = 0;
     $this->pubs = 0;
     $this->subscriptions = [];
     $this->options = $options;
     $randomFactory = new Factory();
     $this->randomGenerator = $randomFactory->getLowStrengthGenerator();
     if (is_null($options)) {
         $this->options = new ConnectionOptions();
     }
 }
开发者ID:repejota,项目名称:phpnats,代码行数:17,代码来源:Connection.php


注:本文中的RandomLib\Factory::getLowStrengthGenerator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。