We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d432ef9 commit 057ef70Copy full SHA for 057ef70
src/Utils/Str.php
@@ -4,6 +4,38 @@
4
5
class Str
6
{
7
+ // string to hex
8
+ public static function stringToHex(?string $string)
9
+ {
10
+ if (!$string) {
11
+ return null;
12
+ }
13
+
14
+ $hex = '';
15
+ for ($i=0; $i < strlen($string); $i++){
16
+ $ord = ord($string[$i]);
17
+ $hexCode = dechex($ord);
18
+ $hex .= substr('0'.$hexCode, -2);
19
20
21
+ return $hex;
22
23
24
+ // hex to string
25
+ public static function hexToString(?string $hex)
26
27
+ if (!$hex) {
28
29
30
31
+ $string = '';
32
+ for ($i=0; $i < strlen($hex); $i+=2){
33
+ $string .= chr(hexdec($hex[$i].$hex[$i+1]));
34
35
36
+ return $string;
37
38
39
// email
40
public static function maskEmail(?string $email = null): ?string
41
0 commit comments