You are here

public static function LockrAesCbcKeyWrapper::reencrypt in Lockr 7.2

Same name and namespace in other branches
  1. 7.3 vendor/lockr/lockr/src/KeyWrapper/LockrAesCbcKeyWrapper.php \Lockr\KeyWrapper\LockrAesCbcKeyWrapper::reencrypt()

Encrypt the given plaintext using the same initial state as defined by encoded.

Parameters

string $plaintext:

string $encoded:

Return value

array

Overrides KeyWrapperInterface::reencrypt

File

vendor/lockr/lockr-client/src/KeyWrapper/LockrAesCbcKeyWrapper.php, line 63

Class

LockrAesCbcKeyWrapper

Namespace

Lockr\KeyWrapper

Code

public static function reencrypt($plaintext, $encoded) {
  $parts = self::decode($encoded);
  if (!$parts) {
    return false;
  }
  list($cipher, $mode, $iv, $key) = $parts;
  $ciphertext = mcrypt_encrypt($cipher, $key, $plaintext, $mode, $iv);
  $ciphertext = base64_encode($ciphertext);
  return array(
    'ciphertext' => $ciphertext,
    'encoded' => $encoded,
  );
}