Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
EncryptHelper.php
1 <?php
2 
4 {
5  /**
6  * Function for encrypt information
7  * @param string $value information that should be encrypted
8  * @return encrypted string
9  */
10  public static function encrypt($value, $withUrl = true){
11  $result = Yii::app()->securityManager->encrypt($value, Yii::app()->securityManager->getEncryptionKey());
12  if($withUrl){
13  $result = urlencode($result);
14  }
15  return $result;
16  }
17  /**
18  * Function for decrypt information
19  * @param string $value information that should be decrypted
20  * @return decrypted string
21  */
22  public static function decrypt($value, $withUrl = true){
23  try{
24  $result = $value;
25  if($withUrl){
26  $result = urldecode($value);
27  }
28  $result = Yii::app()->securityManager->decrypt($result, Yii::app()->securityManager->getEncryptionKey());
29  }catch (Exception $e){
30  $result = false;
31  }
32  return $result;
33  }
34 }