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


PHP RandomGenerator::generateHash方法代码示例

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


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

示例1: onBeforeWrite

 public function onBeforeWrite()
 {
     if (!$this->owner->NewsletterTrackingToken) {
         $generator = new RandomGenerator();
         $this->owner->NewsletterTrackingToken = $generator->generateHash('md5');
     }
 }
开发者ID:nyeholt,项目名称:silverstripe-newsletter-tracking,代码行数:7,代码来源:NewsletterTrackingMemberExtension.php

示例2: onBeforeWrite

 protected function onBeforeWrite()
 {
     if (!$this->isInDB()) {
         $generator = new RandomGenerator();
         $this->Token = $generator->generateHash('sha1');
     }
     parent::onBeforeWrite();
 }
开发者ID:nyeholt,项目名称:silverstripe-eventmanagement,代码行数:8,代码来源:EventRegistration.php

示例3: generateAutologinHash

 /**
  * Generate an auto login hash
  *
  * This creates an auto login hash that can be used to reset the password.
  *
  * @param int $lifetime The lifetime of the auto login hash in days (by default 2 days)
  *
  * @todo Make it possible to handle database errors such as a "duplicate key" error
  */
 function generateAutologinHash($lifetime = 2)
 {
     do {
         $generator = new RandomGenerator();
         $hash = $generator->generateHash('sha1');
     } while (DataObject::get_one('Member', "\"AutoLoginHash\" = '{$hash}'"));
     $this->AutoLoginHash = $hash;
     $this->AutoLoginExpired = date('Y-m-d', time() + 86400 * $lifetime);
     $this->write();
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:19,代码来源:Member.php

示例4: testGenerateHashWithAlgorithm

	function testGenerateHashWithAlgorithm() {
		$r = new RandomGenerator();
		$this->assertNotNull($r->generateHash('md5'));
		$this->assertNotEquals($r->generateHash(), $r->generateHash('md5'));
	}
开发者ID:redema,项目名称:sapphire,代码行数:5,代码来源:RandomGeneratorTest.php

示例5: salt

	/**
	 * Return a string value stored in the {@link Member->Salt} property.
	 * 
	 * @uses RandomGenerator
	 * 
	 * @param String $password Cleartext password
	 * @param Member $member (Optional)
	 * @return String Maximum of 50 characters
	 */
	function salt($password, $member = null) {
		$generator = new RandomGenerator();
		return substr($generator->generateHash('sha1'), 0, 50);
	}
开发者ID:redema,项目名称:sapphire,代码行数:13,代码来源:PasswordEncryptor.php

示例6: generate

	/**
	 * @uses RandomGenerator
	 * 
	 * @return String
	 */
	protected function generate() {
		$generator = new RandomGenerator();
		return $generator->generateHash('sha1');
	}
开发者ID:redema,项目名称:sapphire,代码行数:9,代码来源:SecurityToken.php

示例7: salt

 /**
  * self::$cost param is forced to be two digits with leading zeroes for ints 4-9
  */
 public function salt($password, $member = null)
 {
     $generator = new RandomGenerator();
     return sprintf('%02d', self::$cost) . '$' . substr($generator->generateHash('sha1'), 0, 22);
 }
开发者ID:normann,项目名称:sapphire,代码行数:8,代码来源:PasswordEncryptor.php


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