本文整理汇总了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();
}
示例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();
}
示例4: testGenerateHashWithAlgorithm
function testGenerateHashWithAlgorithm() {
$r = new RandomGenerator();
$this->assertNotNull($r->generateHash('md5'));
$this->assertNotEquals($r->generateHash(), $r->generateHash('md5'));
}
示例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);
}
示例6: generate
/**
* @uses RandomGenerator
*
* @return String
*/
protected function generate() {
$generator = new RandomGenerator();
return $generator->generateHash('sha1');
}
示例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);
}