/**
  * Decode value using the seed that is by default the project's key
  * @param $value the value to decode
  * @param $method the decoding method
  * @param $seed the seed for the decoding
  * @return the decoded value
  */
 public static function decode($value, $method = false, $seed = SECURITY_KEY)
 {
     return Cryptography::cryptographyBuiler($method, $seed)->decodeBuilder($value);
 }
Example #2
0
 public static function check($modelName = DBMODEL_USER)
 {
     if (Session::keyExists('fwLGN')) {
         $auth = new Auth($modelName);
         $val = Cryptography::decode(Session::get('fwLGN'));
         $val = explode(';', $val);
         $asd = array();
         foreach ($val as $valore) {
             $temp = explode(':', $valore);
             $asd[$temp[0]] = $temp[1];
         }
         $auth->setParameters($asd);
         if ($auth->checkDB($auth->checkDB(implode(', ', array_keys($auth->getParameters()))))) {
             return true;
         }
     }
     self::logout();
     return false;
 }
Example #3
0
 public static function generate($length = 64)
 {
     $seed = time() . $_SERVER['REMOTE_ADDR'] . openssl_random_pseudo_bytes($length);
     $seed = Cryptography::encode($seed, 'base64');
     return substr($seed, 0, $length);
 }