Psr7Middlewares\Utils\CryptTrait::encrypt PHP Method

encrypt() private method

Encrypt the given value.
private encrypt ( string $value ) : string
$value string
return string
    private function encrypt($value)
    {
        $this->checkKey();
        $iv = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
        $cipher = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->key, json_encode($value), 'ctr', $iv);
        $hmac = hash_hmac('sha256', $iv . $cipher, $this->authentication, true);
        return base64_encode($hmac . $iv . $cipher);
    }