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


PHP Security::getInstance方法代码示例

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


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

示例1: __password

 function __password($compareTo, $password, $check = true)
 {
     $security = Security::getInstance();
     $salt = Configure::read('Security.salt');
     if ($check === true) {
         if ($security->hash($salt . $password) === $compareTo) {
             return true;
         } else {
             return false;
         }
     } else {
         $genPassword = $security->hash($salt . $password);
         return $genPassword;
     }
 }
开发者ID:simonescu,项目名称:mashupkeyword,代码行数:15,代码来源:user.php

示例2: testHash

 /**
  * testHash method
  *
  * @access public
  * @return void
  */
 function testHash()
 {
     $Security = Security::getInstance();
     $_hashType = $Security->hashType;
     $key = 'someKey';
     $hash = 'someHash';
     $this->assertIdentical(strlen(Security::hash($key, null, false)), 40);
     $this->assertIdentical(strlen(Security::hash($key, 'sha1', false)), 40);
     $this->assertIdentical(strlen(Security::hash($key, null, true)), 40);
     $this->assertIdentical(strlen(Security::hash($key, 'sha1', true)), 40);
     $result = Security::hash($key, null, $hash);
     $this->assertIdentical($result, 'e38fcb877dccb6a94729a81523851c931a46efb1');
     $result = Security::hash($key, 'sha1', $hash);
     $this->assertIdentical($result, 'e38fcb877dccb6a94729a81523851c931a46efb1');
     $hashType = 'sha1';
     Security::setHash($hashType);
     $this->assertIdentical($this->sut->hashType, $hashType);
     $this->assertIdentical(strlen(Security::hash($key, null, true)), 40);
     $this->assertIdentical(strlen(Security::hash($key, null, false)), 40);
     $this->assertIdentical(strlen(Security::hash($key, 'md5', false)), 32);
     $this->assertIdentical(strlen(Security::hash($key, 'md5', true)), 32);
     $hashType = 'md5';
     Security::setHash($hashType);
     $this->assertIdentical($this->sut->hashType, $hashType);
     $this->assertIdentical(strlen(Security::hash($key, null, false)), 32);
     $this->assertIdentical(strlen(Security::hash($key, null, true)), 32);
     if (!function_exists('hash') && !function_exists('mhash')) {
         $this->assertIdentical(strlen(Security::hash($key, 'sha256', false)), 32);
         $this->assertIdentical(strlen(Security::hash($key, 'sha256', true)), 32);
     } else {
         $this->assertIdentical(strlen(Security::hash($key, 'sha256', false)), 64);
         $this->assertIdentical(strlen(Security::hash($key, 'sha256', true)), 64);
     }
     Security::setHash($_hashType);
 }
开发者ID:BGCX067,项目名称:fake-as3-svn-to-git,代码行数:41,代码来源:security.test.php

示例3: setHash

 /**
  * Sets the default hash method for the Security object.  This affects all objects using
  * Security::hash().
  *
  * @param string $hash Method to use (sha1/sha256/md5)
  * @access public
  * @return void
  * @static
  * @see Security::hash()
  */
 function setHash($hash)
 {
     $_this =& Security::getInstance();
     $_this->hashType = $hash;
 }
开发者ID:cls1991,项目名称:ryzomcore,代码行数:15,代码来源:security.php

示例4: setUp

 /**
  * setUp method
  *
  * @access public
  * @return void
  */
 function setUp()
 {
     $this->sut =& Security::getInstance();
 }
开发者ID:quinns,项目名称:REST-API,代码行数:10,代码来源:security.test.php

示例5: cipher

 /**
  * Encrypts/Decrypts a text using the given key.
  *
  * @param string $text Encrypted string to decrypt, normal string to encrypt
  * @param string $key Key to use
  * @return string Encrypted/Decrypted string
  * @access public
  * @static
  */
 function cipher($text, $key)
 {
     if (empty($key)) {
         //trigger_error(__('You cannot use an empty key for Security::cipher()', true), E_USER_WARNING);
         return '';
     }
     $_this =& Security::getInstance();
     if (!defined('CIPHER_SEED')) {
         //This is temporary will change later
         define('CIPHER_SEED', '76859309657453542496749683645');
     }
     srand(CIPHER_SEED);
     $out = '';
     for ($i = 0; $i < strlen($text); $i++) {
         for ($j = 0; $j < ord(substr($key, $i % strlen($key), 1)); $j++) {
             $toss = rand(0, 255);
         }
         $mask = rand(0, 255);
         $out .= chr(ord(substr($text, $i, 1)) ^ $mask);
     }
     return $out;
 }
开发者ID:romelemperado,项目名称:psx,代码行数:31,代码来源:security.php

示例6: __construct

 /**
  * Security class constructor
  */
 function __construct()
 {
     $this->Security = Security::getInstance();
 }
开发者ID:carriercomm,项目名称:pastebin-5,代码行数:7,代码来源:security.php

示例7: generateAuthKey

 /**
  * Generates a unique authkey
  *
  * @return mixed
  * @access public
  */
 function generateAuthKey()
 {
     $_this =& Security::getInstance();
     return $_this->hash(uniqid(rand(), true));
 }
开发者ID:carriercomm,项目名称:pastebin-5,代码行数:11,代码来源:security.php

示例8: cipher

 /**
  * Encripts/Decrypts a text using the given key.
  *
  * @param string $text Encrypted string to decrypt, normal string to encrypt
  * @param string $key Key to use
  * @return string Encrypted/Decrypted string
  * @access public
  * @static
  */
 function cipher($text, $key)
 {
     $_this =& Security::getInstance();
     if (!defined('CIPHER_SEED')) {
         //This is temporary will change later
         define('CIPHER_SEED', '76859309657453542496749683645');
     }
     srand(CIPHER_SEED);
     $out = '';
     for ($i = 0; $i < strlen($text); $i++) {
         for ($j = 0; $j < ord(substr($key, $i % strlen($key), 1)); $j++) {
             $toss = rand(0, 255);
         }
         $mask = rand(0, 255);
         $out .= chr(ord(substr($text, $i, 1)) ^ $mask);
     }
     return $out;
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:27,代码来源:security.php


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