1 | <?php |
||
13 | class Str extends \Prefab |
||
14 | { |
||
15 | /** |
||
16 | * generate random string |
||
17 | * |
||
18 | * @param int $length of password |
||
19 | * @param null|string $chars characters to use for random string |
||
20 | * @return string password |
||
21 | */ |
||
22 | public static function random(int $length = 10, string $chars = null): string |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Generates a hash for a given string |
||
43 | * |
||
44 | * @param string $string to salt |
||
45 | * @param string $pepper string pepper to add to the salted string for extra security |
||
46 | * @return string $encoded |
||
47 | * @link http://php.net/manual/en/function.hash-hmac.php |
||
48 | * @link http://fatfreeframework.com/base#hash |
||
49 | */ |
||
50 | public static function salted(string $string, string $pepper = ''): string |
||
58 | |||
59 | /** |
||
60 | * Generates a hashed password a given string |
||
61 | * |
||
62 | * @param string $string to salt |
||
63 | * @param string $pepper string pepper to add to the salted string for extra security |
||
64 | * @return string $encoded |
||
65 | */ |
||
66 | public static function password(string $string, string $pepper = ''): string |
||
70 | |||
71 | |||
72 | /** |
||
73 | * Compares a hashed password with the hashed value of a given string |
||
74 | * |
||
75 | * @param string $hashed_password a hashed password |
||
76 | * @param string $string to salt |
||
77 | * @param string $pepper string pepper to add to the salted string for extra security |
||
78 | * @return string success on match |
||
79 | */ |
||
80 | public static function passwordVerify(string $hashed_password, string $string, string $pepper = ''): string |
||
84 | |||
85 | |||
86 | /** |
||
87 | * Generate name based md5 UUID (version 3). |
||
88 | * |
||
89 | * @param null|int $len limit the length |
||
90 | * @example '7e57d004-2b97-0e7a-b45f-5387367791cd' |
||
91 | * @copyright Copyright (c) 2011 François Zaninotto and others |
||
92 | * @url https://github.com/fzaninotto/Faker |
||
93 | * @return string $uuid |
||
94 | */ |
||
95 | public static function uuid($len = null): string |
||
141 | |||
142 | /** |
||
143 | * Deserialize a value as an object or array if serialized |
||
144 | * |
||
145 | * @param mixed $value |
||
146 | */ |
||
147 | public static function deserialize($value) |
||
164 | } |
||
165 |