Zymba Documentation
Crypt
object @Crypt() {
convertPublicKeyRSAToPEM(string $exponent, string $modulus): string {}
createIV(string $cipher): string {}
createJWT(object $claims, string $key, string $algorithm, object $header): string {}
createNonce(int $size): string {}
createNonceRaw(int $size): string {}
createPassword(int $length): string {}
createTimeOrderedUUID(): string {}
createUUID(): string {}
decrypt(string $string, string $key, string $cipher, string $iv): string {}
encrypt(string $string, string $key, string $cipher, string $iv): string {}
equalsTimeConstant(string $secret, string $input): bool {}
hash(string $string, string $algorithm, ?string $key): string {}
hashFile(string $path, string $algorithm, ?string $key): string {}
hashFileRaw(string $path, string $algorithm, ?string $key): string {}
hashPassword(string $password): string {}
hashRaw(string $string, string $algorithm, ?string $key): string {}
listCiphers(): object {}
listHashAlgorithms(): object {}
pbkdf2(string $password, string $salt, string $algorithm, int $iterations, int $length): string {}
pbkdf2Raw(string $password, string $salt, string $algorithm, int $iterations, int $length): string {}
verifyJWT(string $jwt, string $key): object {}
verifyPassword(string $password, string $hash): bool {}
}
Static cryptographic functions.
Functions
Creates a version 7 universally unique identifier (UUID) from the current timestamp and a random source according to RFC 4122.
@Crypt.createTimeOrderedUUID(): string
Returns
| Type | Value |
|---|---|
string |
Creates a version 4 universally unique identifier (UUID) from a random source according to RFC 4122.
@Crypt.createUUID(): string
Returns
| Type | Value |
|---|---|
string |
Generates the hash of the content of an existing file in its hexadecimal string representation using a specific algorithm.
@Crypt.hashFile(string $path, string $algorithm, ?string $key): string
Parameters
| Name | Type | Value | Default |
|---|---|---|---|
| path | string | "" | |
| algorithm | string | "sha1" | |
| key | ?string | non-HMAC |
Returns
| Type | Value |
|---|---|
string |
Lists all available hash algorithms.
@Crypt.listHashAlgorithms(): object
Returns
| Type | Value |
|---|---|
object | [algorithm, ...] |
Generatesa a PBKDF2 key derived from a password along with a salt in its hexadecimal string representation using a specific algorithm according to RFC 2898.
@Crypt.pbkdf2(string $password, string $salt, string $algorithm, int $iterations, int $length): string
Parameters
| Name | Type | Value | Default |
|---|---|---|---|
| password | string | "" | |
| salt | string | "" | |
| algorithm | string | "sha1" | |
| iterations | int | 10000 | |
| length | int | full key length |
Returns
| Type | Value |
|---|---|
string |
Generates a PBKDF2 key derived from a password along with a salt as raw binary data using a specific algorithm according to RFC 2898.
@Crypt.pbkdf2Raw(string $password, string $salt, string $algorithm, int $iterations, int $length): string
Parameters
| Name | Type | Value | Default |
|---|---|---|---|
| password | string | "" | |
| salt | string | "" | |
| algorithm | string | "sha1" | |
| iterations | int | 10000 | |
| length | int | full key length |
Returns
| Type | Value |
|---|---|
string |
Verify a JSON Web Token (JWT) against a specific key according to RFC 7519 and returns its header parameters and claims.
@Crypt.verifyJWT(string $jwt, string $key): object
Parameters
| Name | Type | Value | Default |
|---|---|---|---|
| jwt | string | "" | |
| key | string | "" |
Returns
| Type | Value |
|---|---|
object | ["header": [name: value, ...], "claims": [name: value, ...]] |
null |