Indura API

Cypher
in package

Class for encrypting and decrypting data using AES-256-CBC.

This class provides methods to encrypt and decrypt data using the AES-256-CBC encryption algorithm. The key and initialization vector (IV) must be provided in hexadecimal format.

Table of Contents

Properties

$cipher  : string
$iv  : string
$key  : string

Methods

__construct()  : mixed
Class constructor.
decrypt()  : string|null
Decrypts encrypted text.
encrypt()  : string
Encrypts plain text.

Properties

$cipher

private string $cipher

Encryption algorithm used.

$iv

private string $iv

Initialization vector (IV) in binary format.

$key

private string $key

Encryption key in binary format.

Methods

__construct()

Class constructor.

public __construct(string $keyHex, string $ivHex) : mixed
Parameters
$keyHex : string

Encryption key in hexadecimal format.

$ivHex : string

Initialization vector in hexadecimal format.

decrypt()

Decrypts encrypted text.

public decrypt(string $encrypted) : string|null
Parameters
$encrypted : string

Encrypted text in base64.

Return values
string|null

Decrypted text or null if the operation fails.

encrypt()

Encrypts plain text.

public encrypt(string $plaintext) : string
Parameters
$plaintext : string

Plain text to encrypt.

Return values
string

Encrypted text in base64.


        
On this page

Search results