Password
in package
This class provides functions for password encryption and decryption.
Tags
Table of Contents
- decode() : string
- Decrypts a string.
- encode() : string
- Encrypts a string.
- generateSign() : string
- Generates a sign for API communication.
- uniqid() : string
- Generates a random password.
Methods
decode()
Decrypts a string.
public
static decode(string $string, string $password) : string
Decodes the given string using the provided password. Returns the decrypted string. Throws an exception if decryption fails.
Parameters
- $string : string
-
The encoded string to be decrypted (output of encode() function).
- $password : string
-
The encryption key.
Tags
Return values
string —The decrypted string.
encode()
Encrypts a string.
public
static encode(string $string, string $password) : string
Encodes the given string using the provided password. Returns the encrypted string.
Parameters
- $string : string
-
The string to be encrypted.
- $password : string
-
The encryption key.
Return values
string —The encrypted string.
generateSign()
Generates a sign for API communication.
public
static generateSign(array<string|int, mixed> $params, string $secret) : string
Parameters
- $params : array<string|int, mixed>
-
The parameters array.
- $secret : string
-
The secret key.
Return values
string —The generated sign.
uniqid()
Generates a random password.
public
static uniqid([int $length = 13 ]) : string
Parameters
- $length : int = 13
-
The desired length of the password.
Return values
string —The generated password.