Encryption
extends Base
in package
Class to encrypt and decrypt data.
Table of Contents
- STATUS_ACTIVE = 1
- STATUS_WORKING = 2
- TABLE_NAME = 'a_#__encryption'
- TARGET_SETTINGS = 0
- $recommendedMethods : array<string|int, mixed>
- $value : array<string|int, mixed>
- __construct() : mixed
- Constructor.
- createHash() : string
- Function to create a hash.
- createPasswordHash() : string
- Function to create a password hash.
- decrypt() : string
- Function to decrypt data.
- encrypt() : string
- Function to encrypt data.
- generatePassword() : string
- Generate random password.
- generateUserPassword() : string
- Generate user password.
- get() : mixed
- Function to get the value for a given key.
- getArray() : array<string|int, mixed>
- Function to get the array values for a given key.
- getData() : array<string|int, mixed>
- Function to get all the values of the Object.
- getForHtml() : mixed
- Function to get the html encoded value for a given key.
- getForSql() : mixed
- Function to get the value if its safe to use for SQL Query (column).
- getInstance() : self
- Function to get instance.
- getKeys() : array<string|int, string>
- Function to get keys.
- getLengthVector() : int
- Specifies the length of the vector.
- getMethod() : string
- Get method.
- getMethods() : array<string|int, string>
- Returns list method of encryption.
- getOptions() : int
- Get options or options default value(0).
- getTarget() : int
- Get target ID.
- getVector() : string
- Get vector.
- has() : bool
- Function to check if the key exists.
- isActive() : bool
- Checks if encrypt or decrypt is possible.
- isEmpty() : bool
- Function to check if the key is empty.
- isReady() : bool
- Check if the encryption change has been set.
- isRunning() : bool
- Check if the encryption change has started.
- reload() : mixed
- Encryption change.
- remove() : mixed
- Function to remove the value.
- set() : $this
- Function to set the value for a given key.
- setData() : $this
- Function to set all the values.
- verifyPasswordHash() : bool
- Check password hash.
Constants
STATUS_ACTIVE
public
int
STATUS_ACTIVE
= 1
Encryption status
STATUS_WORKING
public
int
STATUS_WORKING
= 2
Encryption status
TABLE_NAME
public
string
TABLE_NAME
= 'a_#__encryption'
Table name
TARGET_SETTINGS
public
int
TARGET_SETTINGS
= 0
The encryption ID for the configuration
Properties
$recommendedMethods
public
static array<string|int, mixed>
$recommendedMethods
= ['aes-256-cbc', 'aes-256-ctr', 'aes-192-cbc', 'aes-192-ctr']
Recommended encryption methods
$value
protected
array<string|int, mixed>
$value
Values
Methods
__construct()
Constructor.
public
__construct([array<string|int, mixed> $values = [] ]) : mixed
Parameters
- $values : array<string|int, mixed> = []
Return values
mixed —createHash()
Function to create a hash.
public
static createHash(string $text) : string
Parameters
- $text : string
Return values
string —createPasswordHash()
Function to create a password hash.
public
static createPasswordHash(string $text, string $pepper) : string
Parameters
- $text : string
- $pepper : string
Return values
string —decrypt()
Function to decrypt data.
public
decrypt(string $encrypted[, bool $testMode = false ]) : string
Parameters
- $encrypted : string
- $testMode : bool = false
Return values
string —encrypt()
Function to encrypt data.
public
encrypt(string $decrypted[, bool $testMode = false ]) : string
Parameters
- $decrypted : string
- $testMode : bool = false
Return values
string —generatePassword()
Generate random password.
public
static generatePassword([int $length = 10 ][, mixed $type = 'lbd' ]) : string
Parameters
- $length : int = 10
- $type : mixed = 'lbd'
Return values
string —generateUserPassword()
Generate user password.
public
static generateUserPassword([int $length = 10 ]) : string
Parameters
- $length : int = 10
Return values
string —get()
Function to get the value for a given key.
public
get(string $key) : mixed
Parameters
- $key : string
Return values
mixed —Value for the given key
getArray()
Function to get the array values for a given key.
public
getArray(string $key[, array<string|int, mixed> $value = [] ]) : array<string|int, mixed>
Parameters
- $key : string
- $value : array<string|int, mixed> = []
Return values
array<string|int, mixed> —getData()
Function to get all the values of the Object.
public
getData() : array<string|int, mixed>
Return values
array<string|int, mixed> —getForHtml()
Function to get the html encoded value for a given key.
public
getForHtml(string $key) : mixed
Parameters
- $key : string
Return values
mixed —getForSql()
Function to get the value if its safe to use for SQL Query (column).
public
getForSql(string $key[, bool $skipEmtpy = true ]) : mixed
Parameters
- $key : string
- $skipEmtpy : bool = true
-
Skip the check if string is empty
Return values
mixed —Value for the given key
getInstance()
Function to get instance.
public
static getInstance([int $target = self::TARGET_SETTINGS ]) : self
Parameters
- $target : int = self::TARGET_SETTINGS
-
self::TARGET_SETTINGS or module ID
Return values
self —getKeys()
Function to get keys.
public
getKeys() : array<string|int, string>
Return values
array<string|int, string> —getLengthVector()
Specifies the length of the vector.
public
static getLengthVector(string $method) : int
Parameters
- $method : string
Return values
int —getMethod()
Get method.
public
getMethod() : string
Return values
string —getMethods()
Returns list method of encryption.
public
static getMethods() : array<string|int, string>
Return values
array<string|int, string> —getOptions()
Get options or options default value(0).
public
getOptions() : int
Return values
int —getTarget()
Get target ID.
public
getTarget() : int
Return values
int —getVector()
Get vector.
public
getVector() : string
Return values
string —has()
Function to check if the key exists.
public
has(string $key) : bool
Parameters
- $key : string
Return values
bool —isActive()
Checks if encrypt or decrypt is possible.
public
isActive([bool $testMode = false ]) : bool
Parameters
- $testMode : bool = false
Return values
bool —isEmpty()
Function to check if the key is empty.
public
isEmpty(string $key) : bool
Parameters
- $key : string
Return values
bool —isReady()
Check if the encryption change has been set.
public
isReady() : bool
Return values
bool —isRunning()
Check if the encryption change has started.
public
isRunning() : bool
Return values
bool —reload()
Encryption change.
public
reload() : mixed
Return values
mixed —remove()
Function to remove the value.
public
remove(string $key) : mixed
Parameters
- $key : string
Return values
mixed —set()
Function to set the value for a given key.
public
set(string $key, mixed $value) : $this
Parameters
- $key : string
- $value : mixed
Return values
$this —setData()
Function to set all the values.
public
setData(mixed $values) : $this
Parameters
- $values : mixed
Return values
$this —verifyPasswordHash()
Check password hash.
public
static verifyPasswordHash(string $password, string $hash, string $pepper) : bool
Parameters
- $password : string
- $hash : string
- $pepper : string