コード例 #1
0
ファイル: Hybrid.php プロジェクト: ezimuel/phpcrypto
 /**
  * Decrypt
  *
  * @param string $msg
  * @param string $privateKey
  * @return string
  * @throws RuntimeException
  */
 public function decrypt(string $msg, string $privateKey = '') : string
 {
     // get the session key
     list($encryptedKey, $ciphertext) = explode(':', $msg, 2);
     // decrypt the session key with privateKey
     $sessionKey = $this->public->decrypt(base64_decode($encryptedKey), $privateKey);
     //openssl_private_decrypt(base64_decode($encryptedKey), $sessionKey, $privateKey, $padding);
     // encrypt the plaintext with symmetric algorithm
     return $this->symmetric->decrypt($ciphertext, $sessionKey);
 }