You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`Crypto::sha256(string $data, bool $binary = false):string`| Generates an SHA-256 hash for the given value |
54
+
|`Crypto::sha512(string $data, bool $binary = false):string`| Generates an SHA-512 hash for the given value |
55
+
|`Crypto::randomString(int $length, string $keyspace = Crypto::ASCII_COMMON_PW):string`| Generates a secure random string of the given `$length`, using the characters (8-bit byte) in the given `$keyspace`. |
56
+
|`Crypto::createEncryptionKey():string`| Creates a new cryptographically secure random encryption key for use with `encrypt()` and `decrypt()` (returned in hexadecimal format) |
57
+
|`Crypto::encrypt(string $data, string $keyHex, int $format = Crypto::ENCRYPT_FORMAT_HEX):string`| Encrypts the given `$data` with `$key`, formats the output according to `$format`\[binary, base64, hex\]|
58
+
|`Crypto::decrypt(string $encrypted, string $keyHex, int $format = Crypto::ENCRYPT_FORMAT_HEX):string`| Decrypts the given `$encrypted` data with `$key` from input formatted according to `$format`\[binary, base64, hex\]|
59
+
60
+
The `Crypto` class defines the following public constants:
61
+
62
+
pre-defined character maps for use with `Crypto::randomString()` as `$keyspace`:
|`Str::filter(array $mixed):array`| Filters an array and removes all elements that are not strings. Array keys are *not* retained |
113
+
|`Str::toUpper(array $strings):array`| Converts the strings in an array to uppercase |
114
+
|`Str::toLower(array $strings):array`| Converts the strings in an array to lowercase |
115
+
|`Str::startsWith(string $haystack, array $needles, bool $ignoreCase = false):bool`| Checks whether the given string starts with *any* of the given array of needles |
116
+
|`Str::containsAll(string $haystack, array $needles, bool $ignoreCase = false):bool`| Checks whether the given string (haystack) contains *all* of the given array of needles |
117
+
|`Str::containsAny(string $haystack, array $needles, bool $ignoreCase = false):bool`| Checks whether the given string (haystack) contains *any* of the given array of needles |
118
+
|`Str::jsonDecode(string $json, bool $associative = false, int $flags = 0):mixed`| Decodes a JSON string |
119
+
|`Str::jsonEncode(mixed $data, int $flags = self::JSON_ENCODE_FLAGS_DEFAULT):string`| Encodes a value into a JSON representation |
120
+
|`Str::base64encode(string $string, int $variant = SODIUM_BASE64_VARIANT_ORIGINAL):string`| Encodes a binary string to base64 (timing-safe) |
121
+
|`Str::base64decode(string $base64, int $variant = SODIUM_BASE64_VARIANT_ORIGINAL):string`| Decodes a base64 string into binary (timing-safe) |
0 commit comments