Exemple #1
0
 /**
  * add(): Make a new nonce, insert in the TABLE, and return it.
  * @return string  New nonce, or false if add failed.
  */
 public static function add()
 {
     self::clean();
     $nonce = TlonHash::hash(TlonHash::salt(), $_SERVER['REMOTE_ADDR']);
     if (TlonData::insert(self::$TABLE, array($nonce, time()))) {
         return $nonce;
     } else {
         return false;
     }
 }
Exemple #2
0
 public function testHash()
 {
     $this->assertEquals(self::EMPTY_HASH, TlonHash::hash(self::SALT, self::EMPTY_STRING));
     $this->assertEquals(self::GRUE_HASH, TlonHash::hash(self::SALT, self::GRUE_STRING));
 }
Exemple #3
0
 /**
  * @return string Authentication token.
  */
 public static function makeAuthToken($prefix = false)
 {
     return TlonHash::hash($prefix == false ? $_SERVER['REMOTE_ADDR'] : $prefix, dechex(time()));
 }