Example #1
0
 /**
  * Verify a key, check if it generated by the website
  *
  * @param string $sessionRawKey The key to check
  * @param string $networkID The unique ID of session's network
  * @param string $for The type of the session
  *
  * @return string The key
  */
 private static function verifyKey($sessionRawKey, $networkID, $for = 'General')
 {
     $key = $rawKey = array();
     $hasher = new Hasher(self::$sessions[$for]['Setting']['Salt'], 1);
     $inputKey = explode("\t", $sessionRawKey, 3);
     if (isset($inputKey[0], $inputKey[1], $inputKey[2])) {
         $key = array('Client' => $inputKey[0], 'Verify' => $inputKey[1], 'Expire' => (int) $inputKey[2]);
         if ($key['Verify'] === $hasher->obscuredVerify($key['Client'] . $networkID)) {
             return $key;
         }
     }
     return false;
 }
Example #2
0
 /**
  * Verify a key, check if it generated by the website
  *
  * @param string $sessionRawKey The key to check
  * @param string $networkID The unique ID of session's network
  * @param string $for The type of the session
  *
  * @return string The key
  */
 protected static function isVerified($sessionRawKey, $networkID, $for = 'General')
 {
     $hasher = null;
     if (!isset($sessionRawKey[0]) || isset($sessionRawKey[64])) {
         return false;
     }
     $hasher = new Hasher(static::$sessions[$for]['Setting']['Salt'], 1);
     $inputKey = explode(static::KEY_SPLITER, $sessionRawKey, 3);
     if (!isset($inputKey[0], $inputKey[1], $inputKey[2])) {
         return false;
     }
     $key = array('Client' => $inputKey[0], 'Verify' => $inputKey[1], 'Expire' => (int) $inputKey[2]);
     if ($key['Verify'] !== substr($hasher->obscuredVerify($key['Client'] . $networkID . $key['Expire']), 8, 16)) {
         return false;
     }
     return $key;
 }