Encrypter

class Encrypter (View source)

Properties

protected string $key The encryption key.
protected string $cipher The algorithm used for encryption.
protected string $mode The mode used for encryption.
protected int $block The block size of the cipher.

Methods

void __construct(string $key)

Create a new encrypter instance.

string encrypt(string $value)

Encrypt the given value.

string padAndMcrypt(string $value, string $iv)

Pad and use mcrypt on the given value and input vector.

string decrypt(string $payload)

Decrypt the given value.

string mcryptDecrypt(string $value, string $iv)

Run the mcrypt decryption routine for the value.

array getJsonPayload(string $payload)

Get the JSON array from the given payload.

bool validMac(array $payload)

Determine if the MAC for the given payload is valid.

string hash(string $iv, string $value)

Create a MAC for the given value.

string addPadding(string $value)

Add PKCS7 padding to a given value.

string stripPadding(string $value)

Remove the padding from the given value.

bool paddingIsValid(string $pad, string $value)

Determine if the given padding for a value is valid.

bool invalidPayload(array|mixed $data)

Verify that the encryption payload is valid.

int getIvSize()

Get the IV size for the cipher.

int getRandomizer()

Get the random data source available for the OS.

void setKey(string $key)

Set the encryption key.

void setCipher(string $cipher)

Set the encryption cipher.

void setMode(string $mode)

Set the encryption mode.

void updateBlockSize()

Update the block size for the current cipher and mode.

Details

void __construct(string $key)

Create a new encrypter instance.

Parameters

string $key

Return Value

void

string encrypt(string $value)

Encrypt the given value.

Parameters

string $value

Return Value

string

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

Pad and use mcrypt on the given value and input vector.

Parameters

string $value
string $iv

Return Value

string

string decrypt(string $payload)

Decrypt the given value.

Parameters

string $payload

Return Value

string

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

Run the mcrypt decryption routine for the value.

Parameters

string $value
string $iv

Return Value

string

Exceptions

Exception

protected array getJsonPayload(string $payload)

Get the JSON array from the given payload.

Parameters

string $payload

Return Value

array

Exceptions

DecryptException

protected bool validMac(array $payload)

Determine if the MAC for the given payload is valid.

Parameters

array $payload

Return Value

bool

Exceptions

RuntimeException

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

Create a MAC for the given value.

Parameters

string $iv
string $value

Return Value

string

protected string addPadding(string $value)

Add PKCS7 padding to a given value.

Parameters

string $value

Return Value

string

protected string stripPadding(string $value)

Remove the padding from the given value.

Parameters

string $value

Return Value

string

protected bool paddingIsValid(string $pad, string $value)

Determine if the given padding for a value is valid.

Parameters

string $pad
string $value

Return Value

bool

protected bool invalidPayload(array|mixed $data)

Verify that the encryption payload is valid.

Parameters

array|mixed $data

Return Value

bool

protected int getIvSize()

Get the IV size for the cipher.

Return Value

int

protected int getRandomizer()

Get the random data source available for the OS.

Return Value

int

void setKey(string $key)

Set the encryption key.

Parameters

string $key

Return Value

void

void setCipher(string $cipher)

Set the encryption cipher.

Parameters

string $cipher

Return Value

void

void setMode(string $mode)

Set the encryption mode.

Parameters

string $mode

Return Value

void

protected void updateBlockSize()

Update the block size for the current cipher and mode.

Return Value

void

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