You are here

public static function LockrAes256CbcSha256KeyWrapper::encrypt in Lockr 7.3

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

Encrypt the given plaintext.

Parameters

string $plaintext:

string|null $key:

Return value

array

Overrides KeyWrapperInterface::encrypt

2 calls to LockrAes256CbcSha256KeyWrapper::encrypt()
LockrAes256CbcSha256KeyWrapperTest::testEncryptsData in vendor/lockr/lockr/tests/KeyWrapper/LockrAes256CbcSha256KeyWrapperTest.php
LockrAes256CbcSha256KeyWrapperTest::testReencryptsData in vendor/lockr/lockr/tests/KeyWrapper/LockrAes256CbcSha256KeyWrapperTest.php

File

vendor/lockr/lockr/src/KeyWrapper/LockrAes256CbcSha256KeyWrapper.php, line 23

Class

LockrAes256CbcSha256KeyWrapper

Namespace

Lockr\KeyWrapper

Code

public static function encrypt($plaintext, $key = null) {
  if (is_null($key)) {
    $key = random_bytes(self::KEY_LEN);
  }
  $iv = random_bytes(self::IV_LEN);
  return self::doEncrypt($plaintext, $key, $iv);
}