class Encrypter extends BaseEncrypter implements Encrypter (View source)

Properties

protected string $key The encryption key. from BaseEncrypter
protected string $cipher The algorithm used for encryption.

Methods

string
hash(string $iv, string $value)

Create a MAC for the given value.

array
getJsonPayload(string $payload)

Get the JSON array from the given payload.

bool
invalidPayload(array|mixed $data)

Verify that the encryption payload is valid.

bool
validMac(array $payload)

Determine if the MAC for the given payload is valid.

void
__construct(string $key, string $cipher = 'AES-128-CBC')

Create a new encrypter instance.

static bool
supported(string $key, string $cipher)

Determine if the given key and cipher combination is valid.

string
encrypt(string $value)

Encrypt the given value.

string
decrypt(string $payload)

Decrypt the given value.

int
getIvSize()

Get the IV size for the cipher.

Details

protected string hash(string $iv, string $value)

Create a MAC for the given value.

Parameters

string $iv
string $value

Return Value

string

protected array getJsonPayload(string $payload)

Get the JSON array from the given payload.

Parameters

string $payload

Return Value

array

Exceptions

DecryptException

protected bool invalidPayload(array|mixed $data)

Verify that the encryption payload is valid.

Parameters

array|mixed $data

Return Value

bool

protected bool validMac(array $payload)

Determine if the MAC for the given payload is valid.

Parameters

array $payload

Return Value

bool

Exceptions

RuntimeException

void __construct(string $key, string $cipher = 'AES-128-CBC')

Create a new encrypter instance.

Parameters

string $key
string $cipher

Return Value

void

Exceptions

RuntimeException

static bool supported(string $key, string $cipher)

Determine if the given key and cipher combination is valid.

Parameters

string $key
string $cipher

Return Value

bool

string encrypt(string $value)

Encrypt the given value.

Parameters

string $value

Return Value

string

Exceptions

EncryptException

string decrypt(string $payload)

Decrypt the given value.

Parameters

string $payload

Return Value

string

Exceptions

DecryptException

protected int getIvSize()

Get the IV size for the cipher.

Return Value

int