Example #1
0
 /**
  * Static method to return the decoded GET paramters from an encrytpted tk value as an array of key/value pairs.
  *
  * @return array
  *
  * @since 1.0
  */
 public static function getDecodeQueryParams($tk)
 {
     $config = ConfigProvider::getInstance();
     // replace any troublesome characters from the URL with the original values
     $token = strtr($tk, '-_', '+/');
     $token = base64_decode($token);
     $params = SecurityUtils::decrypt($token);
     $pairs = explode('&', $params);
     $parameters = array();
     foreach ($pairs as $pair) {
         $split = explode('=', $pair);
         $parameters[$split[0]] = $split[1];
     }
     return $parameters;
 }
Example #2
0
 /**
  * Testing encrypt/decrypt methods.
  *
  * @since 2.0.2
  */
 public function testEncryptDecrypt()
 {
     $plain = "test string";
     $encrypted = SecurityUtils::encrypt($plain);
     $this->assertEquals($plain, SecurityUtils::decrypt($encrypted), "Testing encrypt/decrypt methods");
 }
Example #3
0
 /**
  * Descrypts the HTTP param fieldnames in the array provided and returns the plain version.
  *
  * @param $params array
  *
  * @return array
  * 
  * @since 1.2.2
  */
 private function decryptFieldNames($params)
 {
     $decrypted = array();
     foreach (array_keys($params) as $fieldname) {
         // set request params where fieldnames provided are based64 encoded and encrypted
         if (Validator::isBase64($fieldname)) {
             $decrypted[SecurityUtils::decrypt(base64_decode($fieldname))] = $params[$fieldname];
         }
     }
     return $decrypted;
 }