Psr7Middlewares\Utils\CryptTrait::decrypt PHP Method

decrypt() private method

Decrypt the given value.
private decrypt ( string $value ) : string
$value string
return string
    private function decrypt($value)
    {
        $this->checkKey();
        $decoded = base64_decode($value);
        $hmac = mb_substr($decoded, 0, 32, '8bit');
        $iv = mb_substr($decoded, 32, 16, '8bit');
        $cipher = mb_substr($decoded, 48, null, '8bit');
        $calculated = hash_hmac('sha256', $iv . $cipher, $this->authentication, true);
        if (Helpers::hashEquals($hmac, $calculated)) {
            $value = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this->key, $cipher, 'ctr', $iv), "");
            return json_decode($value, true);
        }
    }