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
Create a new encrypter instance.
Encrypt the given value.
Pad and use mcrypt on the given value and input vector.
Decrypt the given value.
Run the mcrypt decryption routine for the value.
Get the JSON array from the given payload.
Determine if the MAC for the given payload is valid.
Create a MAC for the given value.
Add PKCS7 padding to a given value.
Remove the padding from the given value.
Determine if the given padding for a value is valid.
Verify that the encryption payload is valid.
Get the IV size for the cipher.
Get the random data source available for the OS.
Set the encryption key.
Set the encryption cipher.
Set the encryption mode.
Update the block size for the current cipher and mode.
Details
void
__construct(string $key)
Create a new encrypter instance.
string
encrypt(string $value)
Encrypt the given value.
protected 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.
protected string
mcryptDecrypt(string $value, string $iv)
Run the mcrypt decryption routine for the value.
protected array
getJsonPayload(string $payload)
Get the JSON array from the given payload.
protected bool
validMac(array $payload)
Determine if the MAC for the given payload is valid.
protected string
hash(string $iv, string $value)
Create a MAC for the given value.
protected string
addPadding(string $value)
Add PKCS7 padding to a given value.
protected string
stripPadding(string $value)
Remove the padding from the given value.
protected bool
paddingIsValid(string $pad, string $value)
Determine if the given padding for a value is valid.
protected bool
invalidPayload(array|mixed $data)
Verify that the encryption payload is valid.
protected int
getIvSize()
Get the IV size for the cipher.
protected 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.
protected void
updateBlockSize()
Update the block size for the current cipher and mode.