Example #1
0
 /**
  * @param string $sString
  * @param string $sKey = ''
  *
  * @return string|false
  */
 public static function DecryptStringRSA($sString, $sKey = '')
 {
     $sResult = '';
     $sKey = \md5($sKey);
     $sPrivateKey = \RainLoop\Utils::RsaPrivateKey();
     if (!empty($sPrivateKey) && !empty($sString)) {
         $oPrivKey = \openssl_pkey_get_private($sPrivateKey);
         $aString = @\unserialize($sString);
         if (\is_array($aString)) {
             if ($sKey === \array_pop($aString)) {
                 foreach ($aString as $iIndex => $sLine) {
                     $sDecrypted = '';
                     \openssl_private_decrypt($sLine, $sDecrypted, $oPrivKey);
                     $aString[$iIndex] = $sDecrypted;
                 }
                 $sResult = \implode('', $aString);
             }
         }
         \openssl_free_key($oPrivKey);
     }
     return $sResult;
 }