passwordHandler
in package
Password handling class
Table of Contents
- $charUniverse : string
- checkPassword() : bool
- Checks if a password belongs to a hashed version
- createPassword() : array<string|int, mixed>
- Creates a password object out of a raw password
- setCharUniverse() : mixed
- Sets a custom string for pepper chars. This method allows to create custom pepper sets.
- customAlg() : mixed
- Custom spagetti logic
- customAlgEnc() : mixed
- Encryption function: uses str as key
- generateCheckOptions() : array<string|int, string>
- Function to generate all Pepper options
- generatePepper() : string
- Generates pepper using the set charUniverse
- generateSalt() : string
- Generates a salt
- hashStr() : string
- Hashes a string with sha512
- processStr() : string
- Processes a password
Properties
$charUniverse
private
static string
$charUniverse
= "abcdefghijklmnopqrstuvwxyz"
String with all possible pepper chars
Methods
checkPassword()
Checks if a password belongs to a hashed version
public
static checkPassword(string $userInput, string $hash, string $salt) : bool
Parameters
- $userInput : string
-
The raw password
- $hash : string
-
The hash to check
- $salt : string
-
The used salt
Return values
bool —True when password matches
createPassword()
Creates a password object out of a raw password
public
static createPassword(string $userInput) : array<string|int, mixed>
Parameters
- $userInput : string
-
The raw password
Return values
array<string|int, mixed> —The generated password object
setCharUniverse()
Sets a custom string for pepper chars. This method allows to create custom pepper sets.
public
static setCharUniverse(string $charUniverseParam) : mixed
Parameters
- $charUniverseParam : string
-
A string containing new all possible pepper chars
Return values
mixed —customAlg()
Custom spagetti logic
private
static customAlg(mixed $str) : mixed
Parameters
- $str : mixed
Return values
mixed —customAlgEnc()
Encryption function: uses str as key
private
static customAlgEnc(string $string) : mixed
Parameters
- $string : string
-
The key
Return values
mixed —generateCheckOptions()
Function to generate all Pepper options
private
static generateCheckOptions(string $userInput, string $salt) : array<string|int, string>
Parameters
- $userInput : string
-
The raw password
- $salt : string
-
A salt
Return values
array<string|int, string> —possible options
generatePepper()
Generates pepper using the set charUniverse
private
static generatePepper() : string
Return values
string —Pepper
generateSalt()
Generates a salt
private
static generateSalt() : string
Return values
string —A salt
hashStr()
Hashes a string with sha512
private
static hashStr(string $str) : string
Parameters
- $str : string
-
The input string
Return values
string —The hashed version of the input string
processStr()
Processes a password
private
static processStr(string $str) : string
Parameters
- $str : string
-
The raw password
Return values
string —A finished hashed, salted and peppered password to save somewhere