You are here

public static function LockrAesCbcKeyWrapper::reencrypt 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::reencrypt()

Encrypt the given plaintext reusing state.

Parameters

string $plaintext:

string $wrapping_key:

Return value

array

Overrides KeyWrapperInterface::reencrypt

1 call to LockrAesCbcKeyWrapper::reencrypt()
LockrAesCbcKeyWrapperTest::testReencryptsData in vendor/lockr/lockr/tests/KeyWrapper/LockrAesCbcKeyWrapperTest.php
@requires function mcrypt_encrypt

File

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

Class

LockrAesCbcKeyWrapper

Namespace

Lockr\KeyWrapper

Code

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