Documentation

Encrypter
in package
implements Encrypter

Interfaces, Classes and Traits

Encrypter

Table of Contents

$cipher  : string
The algorithm used for encryption.
$key  : string
The encryption key.
__construct()  : void
Create a new encrypter instance.
decrypt()  : string
Decrypt the given value.
decryptString()  : string
Decrypt the given string without unserialization.
encrypt()  : string
Encrypt the given value.
encryptString()  : string
Encrypt a string without serialization.
generateKey()  : string
Create a new encryption key for the given cipher.
getKey()  : string
Get the encryption key.
supported()  : bool
Determine if the given key and cipher combination is valid.
calculateMac()  : string
Calculate the hash of the given payload.
getJsonPayload()  : array<string|int, mixed>
Get the JSON array from the given payload.
hash()  : string
Create a MAC for the given value.
validMac()  : bool
Determine if the MAC for the given payload is valid.
validPayload()  : bool
Verify that the encryption payload is valid.

Properties

$cipher

The algorithm used for encryption.

protected string $cipher

$key

The encryption key.

protected string $key

Methods

__construct()

Create a new encrypter instance.

public __construct(string $key[, string $cipher = 'AES-128-CBC' ]) : void
Parameters
$key : string
$cipher : string = 'AES-128-CBC'
Tags
throws
RuntimeException
Return values
void

decrypt()

Decrypt the given value.

public decrypt(mixed $payload[, bool $unserialize = true ]) : string
Parameters
$payload : mixed
$unserialize : bool = true
Tags
throws
DecryptException
Return values
string

decryptString()

Decrypt the given string without unserialization.

public decryptString(string $payload) : string
Parameters
$payload : string
Return values
string

encrypt()

Encrypt the given value.

public encrypt(mixed $value[, bool $serialize = true ]) : string
Parameters
$value : mixed
$serialize : bool = true
Tags
throws
EncryptException
Return values
string

encryptString()

Encrypt a string without serialization.

public encryptString(string $value) : string
Parameters
$value : string
Return values
string

generateKey()

Create a new encryption key for the given cipher.

public static generateKey(string $cipher) : string
Parameters
$cipher : string
Return values
string

getKey()

Get the encryption key.

public getKey() : string
Return values
string

supported()

Determine if the given key and cipher combination is valid.

public static supported(string $key, string $cipher) : bool
Parameters
$key : string
$cipher : string
Return values
bool

calculateMac()

Calculate the hash of the given payload.

protected calculateMac(array<string|int, mixed> $payload, string $bytes) : string
Parameters
$payload : array<string|int, mixed>
$bytes : string
Return values
string

getJsonPayload()

Get the JSON array from the given payload.

protected getJsonPayload(string $payload) : array<string|int, mixed>
Parameters
$payload : string
Tags
throws
DecryptException
Return values
array<string|int, mixed>

hash()

Create a MAC for the given value.

protected hash(string $iv, mixed $value) : string
Parameters
$iv : string
$value : mixed
Return values
string

validMac()

Determine if the MAC for the given payload is valid.

protected validMac(array<string|int, mixed> $payload) : bool
Parameters
$payload : array<string|int, mixed>
Return values
bool

validPayload()

Verify that the encryption payload is valid.

protected validPayload(mixed $payload) : bool
Parameters
$payload : mixed
Return values
bool

Search results