\security

Security class

Vars checking, token generating, encrypting

Summary

Methods
Properties
Constants
filter()
clean()
token_str()
encrypt()
decrypt()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

filter()

filter(mixed  $a, boolean  $n = false) : mixed

Var filter

Make variables and arrays secure and clear

Parameters

mixed $a

Var to check

boolean $n

Output check. If true - types won't be changed

Throws

\apiException
  • [103] Checking failed

Returns

mixed —

Checked var

clean()

clean(mixed  $a, boolean  $n = false) : mixed

Var clean

Make variables clear and correct

Parameters

mixed $a

Var to check

boolean $n

Output check. If true - types won't be changed

Returns

mixed —

Result

token_str()

token_str(integer  $l = 64) : string

Get Token

Generates crypt-secure random string for token (HEX)

Parameters

integer $l

Token length

Returns

string —

Token

encrypt()

encrypt(string  $plaintext, array  $o = array()) : array<mixed,string>|boolean

Encrypt

Encrypts text

Parameters

string $plaintext

Text to encrypt

array $o

Options

  • key - salt cipher - encryption method. Default = aes-128-gcm

Returns

array<mixed,string>|boolean —

Returns [$encrypted, $iv, $tag, $key ] or false if failed

decrypt()

decrypt(string  $ciphertext, string  $key, string  $iv, string  $tag, array  $o = array()) : string|boolean

Decrypt

Decrypts string

Parameters

string $ciphertext

Encodedtext

string $key

Key

string $iv

IV

string $tag

Tag

array $o

Options

  • cipher - Encryption method. Default = aes-128-gcm

Returns

string|boolean —

Result. If false - failed.