Encrypter
extends AbstractEncrypter
in package
Pop Crypt encrypter
Tags
Table of Contents
Constants
- AES_128_CBC = 'aes-128-cbc'
- Cipher constants
- AES_128_GCM = 'aes-128-gcm'
- AES_256_CBC = 'aes-256-cbc'
- AES_256_GCM = 'aes-256-gcm'
Properties
- $cipher : string
- Encryption cipher
- $key : string|null
- Encryption Key
- $previousKeys : array<string|int, mixed>
- Previous keys
- $ciphers : array<string|int, mixed>
- Available ciphers
Methods
- __construct() : mixed
- Constructor
- create() : static
- Create encrypter object
- decrypt() : mixed
- Decrypt value
- encrypt() : string
- Encrypt value
- generateKey() : string
- Generate encryption key
- getAllKeys() : array<string|int, mixed>
- Get all keys
- getCipher() : string
- Get cipher
- getKey() : string
- Get key
- getPreviousKeys() : array<string|int, mixed>
- Get previous keys
- hasCipher() : bool
- Has cipher
- hasKey() : bool
- Has key
- hasPreviousKeys() : bool
- Has previous keys
- isAvailable() : bool
- Determine if the cipher is available
- isValid() : bool
- Determine if the key and cipher combination is valid
- setCipher() : static
- Set cipher
- setKey() : static
- Set key
- setPreviousKeys() : static
- Set previous keys
Constants
AES_128_CBC
Cipher constants
public
mixed
AES_128_CBC
= 'aes-128-cbc'
AES_128_GCM
public
mixed
AES_128_GCM
= 'aes-128-gcm'
AES_256_CBC
public
mixed
AES_256_CBC
= 'aes-256-cbc'
AES_256_GCM
public
mixed
AES_256_GCM
= 'aes-256-gcm'
Properties
$cipher
Encryption cipher
protected
string
$cipher
= 'aes-256-cbc'
$key
Encryption Key
protected
string|null
$key
= null
$previousKeys
Previous keys
protected
array<string|int, mixed>
$previousKeys
= []
$ciphers
Available ciphers
private
static array<string|int, mixed>
$ciphers
= ['aes-128-cbc' => ['size' => 16, 'aead' => false], 'aes-256-cbc' => ['size' => 32, 'aead' => false], 'aes-128-gcm' => ['size' => 16, 'aead' => true], 'aes-256-gcm' => ['size' => 32, 'aead' => true]]
Methods
__construct()
Constructor
public
__construct(string $key[, string $cipher = 'aes-256-cbc' ][, bool $raw = true ]) : mixed
Instantiate the Encrypter object
Parameters
- $key : string
- $cipher : string = 'aes-256-cbc'
- $raw : bool = true
Tags
create()
Create encrypter object
public
static create([string $cipher = 'aes-256-cbc' ]) : static
Parameters
- $cipher : string = 'aes-256-cbc'
Return values
staticdecrypt()
Decrypt value
public
decrypt(string $payload) : mixed
Parameters
- $payload : string
Tags
encrypt()
Encrypt value
public
encrypt(mixed $value) : string
Parameters
- $value : mixed
Return values
stringgenerateKey()
Generate encryption key
public
static generateKey(string $cipher[, bool $raw = true ]) : string
Parameters
- $cipher : string
- $raw : bool = true
Return values
stringgetAllKeys()
Get all keys
public
getAllKeys() : array<string|int, mixed>
Return values
array<string|int, mixed>getCipher()
Get cipher
public
getCipher() : string
Return values
stringgetKey()
Get key
public
getKey([bool $raw = false ]) : string
Parameters
- $raw : bool = false
Return values
stringgetPreviousKeys()
Get previous keys
public
getPreviousKeys([bool $raw = false ]) : array<string|int, mixed>
Parameters
- $raw : bool = false
Return values
array<string|int, mixed>hasCipher()
Has cipher
public
hasCipher() : bool
Return values
boolhasKey()
Has key
public
hasKey() : bool
Return values
boolhasPreviousKeys()
Has previous keys
public
hasPreviousKeys() : bool
Return values
boolisAvailable()
Determine if the cipher is available
public
static isAvailable(string $cipher) : bool
Parameters
- $cipher : string
Return values
boolisValid()
Determine if the key and cipher combination is valid
public
static isValid(string $key, string $cipher[, bool $raw = true ]) : bool
Parameters
- $key : string
- $cipher : string
- $raw : bool = true
Return values
boolsetCipher()
Set cipher
public
setCipher(string $cipher) : static
Parameters
- $cipher : string
Return values
staticsetKey()
Set key
public
setKey(string $key[, bool $raw = true ]) : static
Parameters
- $key : string
- $raw : bool = true
Return values
staticsetPreviousKeys()
Set previous keys
public
setPreviousKeys(array<string|int, mixed> $previousKeys[, bool $raw = true ]) : static
Parameters
- $previousKeys : array<string|int, mixed>
- $raw : bool = true