You are here

public static function LockrAesCbcKeyWrapper::decrypt in Lockr 7.3

Same name and namespace in other branches
  1. 7.2 vendor/lockr/lockr-client/src/KeyWrapper/LockrAesCbcKeyWrapper.php \Lockr\KeyWrapper\LockrAesCbcKeyWrapper::decrypt()

Decrypt the given ciphertext.

Parameters

string $ciphertext:

string $wrapping_key:

Return value

string|bool

Overrides KeyWrapperInterface::decrypt

2 calls to LockrAesCbcKeyWrapper::decrypt()
LockrAesCbcKeyWrapperTest::testEncryptsData in vendor/lockr/lockr/tests/KeyWrapper/LockrAesCbcKeyWrapperTest.php
@requires function mcrypt_encrypt
LockrAesCbcKeyWrapperTest::testReencryptsData in vendor/lockr/lockr/tests/KeyWrapper/LockrAesCbcKeyWrapperTest.php
@requires function mcrypt_encrypt

File

vendor/lockr/lockr/src/KeyWrapper/LockrAesCbcKeyWrapper.php, line 59

Class

LockrAesCbcKeyWrapper

Namespace

Lockr\KeyWrapper

Code

public static function decrypt($ciphertext, $wrapping_key) {
  $parts = self::decode($wrapping_key);
  if (!$parts) {
    return false;
  }
  list($cipher, $mode, $iv, $key) = $parts;
  $ciphertext = base64_decode($ciphertext);
  $plaintext = mcrypt_decrypt($cipher, $key, $ciphertext, $mode, $iv);
  if ($plaintext === false) {
    return false;
  }
  return trim($plaintext);
}