Encrypter

class Encrypter implements Encrypter (View source)

Properties

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

Methods

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.

static string generateKey(string $cipher)

Create a new encryption key for the given cipher.

string encrypt(string $value, bool $serialize = true)

Encrypt the given value.

string encryptString(string $value)

Encrypt a string without serialization.

string decrypt(string $payload, bool $unserialize = true)

Decrypt the given value.

string decryptString(string $payload)

Decrypt the given string without unserialization.

string hash(string $iv, mixed $value)

Create a MAC for the given value.

array getJsonPayload(string $payload)

Get the JSON array from the given payload.

bool validPayload(mixed $payload)

Verify that the encryption payload is valid.

bool validMac(array $payload)

Determine if the MAC for the given payload is valid.

string calculateMac(array $payload, string $bytes)

Calculate the hash of the given payload.

string getKey()

Get the encryption key.

Details

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

static string generateKey(string $cipher)

Create a new encryption key for the given cipher.

Parameters

string $cipher

Return Value

string

string encrypt(string $value, bool $serialize = true)

Encrypt the given value.

Parameters

string $value
bool $serialize

Return Value

string

Exceptions

EncryptException

string encryptString(string $value)

Encrypt a string without serialization.

Parameters

string $value

Return Value

string

string decrypt(string $payload, bool $unserialize = true)

Decrypt the given value.

Parameters

string $payload
bool $unserialize

Return Value

string

Exceptions

DecryptException

string decryptString(string $payload)

Decrypt the given string without unserialization.

Parameters

string $payload

Return Value

string

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

Create a MAC for the given value.

Parameters

string $iv
mixed $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 validPayload(mixed $payload)

Verify that the encryption payload is valid.

Parameters

mixed $payload

Return Value

bool

protected bool validMac(array $payload)

Determine if the MAC for the given payload is valid.

Parameters

array $payload

Return Value

bool

protected string calculateMac(array $payload, string $bytes)

Calculate the hash of the given payload.

Parameters

array $payload
string $bytes

Return Value

string

string getKey()

Get the encryption key.

Return Value

string

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.7/Illuminate/Encryption/Encrypter.html