protected static function LockrAes256CbcSha256KeyWrapper::doEncrypt in Lockr 7.3
Same name and namespace in other branches
- 7.2 vendor/lockr/lockr-client/src/KeyWrapper/LockrAes256CbcSha256KeyWrapper.php \Lockr\KeyWrapper\LockrAes256CbcSha256KeyWrapper::doEncrypt()
2 calls to LockrAes256CbcSha256KeyWrapper::doEncrypt()
- LockrAes256CbcSha256KeyWrapper::encrypt in vendor/
lockr/ lockr/ src/ KeyWrapper/ LockrAes256CbcSha256KeyWrapper.php - Encrypt the given plaintext.
- LockrAes256CbcSha256KeyWrapper::reencrypt in vendor/
lockr/ lockr/ src/ KeyWrapper/ LockrAes256CbcSha256KeyWrapper.php - Encrypt the given plaintext reusing state.
File
- vendor/
lockr/ lockr/ src/ KeyWrapper/ LockrAes256CbcSha256KeyWrapper.php, line 74
Class
Namespace
Lockr\KeyWrapperCode
protected static function doEncrypt($plaintext, $key, $iv) {
$key_data = hash('sha512', $key, true);
$enc_key = substr($key_data, 0, self::KEY_LEN);
$hmac_key = substr($key_data, self::KEY_LEN);
$ciphertext = openssl_encrypt($plaintext, self::METHOD, $enc_key, OPENSSL_RAW_DATA, $iv);
$hmac = self::hmac($iv, $ciphertext, $hmac_key);
return [
'ciphertext' => base64_encode($iv . $ciphertext . $hmac),
'encoded' => self::PREFIX . base64_encode($key),
];
}