Crypto
extends Base
in package
Crypto
A class to handle encryption and hashing
Table of Contents
Properties
- $author : mixed
- $debug_log : mixed
- $debugger : mixed
- $name : mixed
- $url : mixed
- $vars : mixed
- $verbose : mixed
- $version : mixed
Methods
- __construct() : mixed
- decryptwithpw() : string
- Decrypt a string using a password, and optionally an IV
- encryptwithpw() : string
- Encrypt a string using a password, and optionally an IV
- genIV() : string
- Generates a random IV for the given encryption method
- hash() : string
- hash
- verifyhash() : bool
- verifyhash
Properties
$author
public
mixed
$author
= "Darknetzz"
$debug_log
public
mixed
$debug_log
= []
$debugger
public
mixed
$debugger
$name
public
mixed
$name
= "PHPUtils"
$url
public
mixed
$url
= "https://github.com/Darknetzz"
$vars
public
mixed
$vars
$verbose
public
mixed
$verbose
= \true
$version
public
mixed
$version
= "1.0.0"
Methods
__construct()
public
__construct() : mixed
decryptwithpw()
Decrypt a string using a password, and optionally an IV
public
decryptwithpw(mixed $str, mixed $password[, mixed $method = 'aes-256-cbc' ][, mixed $iv = '' ]) : string
Parameters
- $str : mixed
-
The string to decrypt
- $password : mixed
-
The password to use
- $method : mixed = 'aes-256-cbc'
-
The encryption method to use. Defaults to aes-256-cbc
- $iv : mixed = ''
-
Whether to use an IV or not. Defaults to ''
Return values
string —The decrypted string
encryptwithpw()
Encrypt a string using a password, and optionally an IV
public
encryptwithpw(mixed $str, mixed $password[, mixed $method = 'aes-256-cbc' ][, mixed $iv = false ]) : string
Parameters
- $str : mixed
-
The string to encrypt
- $password : mixed
-
The password to use
- $method : mixed = 'aes-256-cbc'
-
The encryption method to use. Defaults to aes-256-cbc
- $iv : mixed = false
-
Whether to use an IV or not. Defaults to false
Return values
string —The encrypted string
genIV()
Generates a random IV for the given encryption method
public
genIV(mixed $method) : string
Parameters
- $method : mixed
-
The encryption method to use
Return values
string —The generated IV
hash()
hash
public
hash(mixed $str[, mixed $hash = 'sha512' ]) : string
Parameters
- $str : mixed
-
The string to hash
- $hash : mixed = 'sha512'
-
The hash method to use. Defaults to sha512
Return values
string —The hashed string
verifyhash()
verifyhash
public
verifyhash(mixed $str, mixed $hash[, mixed $hashmethod = 'sha512' ]) : bool
Verifies a hash
Parameters
- $str : mixed
-
The string to verify
- $hash : mixed
-
The hash to verify against
- $hashmethod : mixed = 'sha512'
-
The hash method to use. Defaults to sha512
Return values
bool —Whether the hash is valid or not