@@ -3,17 +3,17 @@ |
||
| 3 | 3 | |
| 4 | 4 | interface Suitin |
| 5 | 5 | {
|
| 6 | - public function cost($cost); |
|
| 6 | + public function cost($cost); |
|
| 7 | 7 | |
| 8 | - public function memory($memory); |
|
| 8 | + public function memory($memory); |
|
| 9 | 9 | |
| 10 | - public function time($time); |
|
| 10 | + public function time($time); |
|
| 11 | 11 | |
| 12 | - public function thread($thread); |
|
| 12 | + public function thread($thread); |
|
| 13 | 13 | |
| 14 | - public function pwHash($mode, $password); |
|
| 14 | + public function pwHash($mode, $password); |
|
| 15 | 15 | |
| 16 | - public function pwRehash($mode, $password, $hash); |
|
| 16 | + public function pwRehash($mode, $password, $hash); |
|
| 17 | 17 | |
| 18 | - public function pwInfo($hash); |
|
| 18 | + public function pwInfo($hash); |
|
| 19 | 19 | } |
@@ -19,35 +19,35 @@ discard block |
||
| 19 | 19 | class Pwsuit |
| 20 | 20 | {
|
| 21 | 21 | /** |
| 22 | - * @param int $cost |
|
| 23 | - */ |
|
| 22 | + * @param int $cost |
|
| 23 | + */ |
|
| 24 | 24 | protected static $cost; |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * @param int $memory |
|
| 28 | - */ |
|
| 27 | + * @param int $memory |
|
| 28 | + */ |
|
| 29 | 29 | protected static $memory; |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * @param int $time |
|
| 33 | - */ |
|
| 32 | + * @param int $time |
|
| 33 | + */ |
|
| 34 | 34 | protected static $time; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * @param int $thread |
|
| 38 | - */ |
|
| 37 | + * @param int $thread |
|
| 38 | + */ |
|
| 39 | 39 | protected static $thread; |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * Set default |
|
| 43 | - */ |
|
| 42 | + * Set default |
|
| 43 | + */ |
|
| 44 | 44 | const DEFAULT = 'Default'; |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * Require minimum PHP 5.6+ |
|
| 48 | - * |
|
| 49 | - * @throws RuntimeException |
|
| 50 | - */ |
|
| 47 | + * Require minimum PHP 5.6+ |
|
| 48 | + * |
|
| 49 | + * @throws RuntimeException |
|
| 50 | + */ |
|
| 51 | 51 | public function __construct() |
| 52 | 52 | {
|
| 53 | 53 | if (version_compare(PHP_VERSION, '5.6.0', '<')) {
|
@@ -56,16 +56,16 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * Create cost length |
|
| 60 | - * |
|
| 61 | - * if it doesn't set by default a cost will set to 14 |
|
| 62 | - * do not set under native default by php |
|
| 63 | - * native default by php set to 10 |
|
| 64 | - * |
|
| 65 | - * @param int $length |
|
| 66 | - * @return array |
|
| 67 | - * |
|
| 68 | - */ |
|
| 59 | + * Create cost length |
|
| 60 | + * |
|
| 61 | + * if it doesn't set by default a cost will set to 14 |
|
| 62 | + * do not set under native default by php |
|
| 63 | + * native default by php set to 10 |
|
| 64 | + * |
|
| 65 | + * @param int $length |
|
| 66 | + * @return array |
|
| 67 | + * |
|
| 68 | + */ |
|
| 69 | 69 | public static function cost(int $length) |
| 70 | 70 | {
|
| 71 | 71 | static::$cost[Verbal::DEFAULT_COST] = $length; |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | - * Create memory_cost length |
|
| 78 | - * |
|
| 79 | - * This is optional by default memory_cost will set to 1666 |
|
| 80 | - * do not set under native default by php |
|
| 81 | - * native default by php set to 1024 |
|
| 82 | - * |
|
| 83 | - * @param int $length |
|
| 84 | - * @return array |
|
| 85 | - * |
|
| 86 | - */ |
|
| 77 | + * Create memory_cost length |
|
| 78 | + * |
|
| 79 | + * This is optional by default memory_cost will set to 1666 |
|
| 80 | + * do not set under native default by php |
|
| 81 | + * native default by php set to 1024 |
|
| 82 | + * |
|
| 83 | + * @param int $length |
|
| 84 | + * @return array |
|
| 85 | + * |
|
| 86 | + */ |
|
| 87 | 87 | public static function memory(int $length) |
| 88 | 88 | {
|
| 89 | 89 | static::$memory[Verbal::MEMORY_KEY] = $length; |
@@ -92,15 +92,15 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | - * Create time_cost length |
|
| 96 | - * |
|
| 97 | - * This is optional by default time_cost will set to 6 |
|
| 98 | - * do not set under native default by php |
|
| 99 | - * native default by php set to 2 |
|
| 100 | - * |
|
| 101 | - * @param int $length |
|
| 102 | - * @return array |
|
| 103 | - */ |
|
| 95 | + * Create time_cost length |
|
| 96 | + * |
|
| 97 | + * This is optional by default time_cost will set to 6 |
|
| 98 | + * do not set under native default by php |
|
| 99 | + * native default by php set to 2 |
|
| 100 | + * |
|
| 101 | + * @param int $length |
|
| 102 | + * @return array |
|
| 103 | + */ |
|
| 104 | 104 | public function time(int $length) |
| 105 | 105 | {
|
| 106 | 106 | static::$time[Verbal::TIME_KEY] = $length; |
@@ -109,15 +109,15 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | - * Create threads length |
|
| 113 | - * |
|
| 114 | - * This is optional by default threads will set to 6 |
|
| 115 | - * do not set under native default by php |
|
| 116 | - * native default by php set to 2 |
|
| 117 | - * |
|
| 118 | - * @param int $length |
|
| 119 | - * @return array |
|
| 120 | - */ |
|
| 112 | + * Create threads length |
|
| 113 | + * |
|
| 114 | + * This is optional by default threads will set to 6 |
|
| 115 | + * do not set under native default by php |
|
| 116 | + * native default by php set to 2 |
|
| 117 | + * |
|
| 118 | + * @param int $length |
|
| 119 | + * @return array |
|
| 120 | + */ |
|
| 121 | 121 | public function thread(int $length) |
| 122 | 122 | {
|
| 123 | 123 | static::$thread[Verbal::THREAD_KEY] = $length; |
@@ -126,45 +126,45 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | - * Check attributes operation |
|
| 130 | - * |
|
| 131 | - * @return array |
|
| 132 | - */ |
|
| 129 | + * Check attributes operation |
|
| 130 | + * |
|
| 131 | + * @return array |
|
| 132 | + */ |
|
| 133 | 133 | protected static function getLength() |
| 134 | 134 | {
|
| 135 | 135 | return isset(static::$cost) ? static::$cost : static::costLength(); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | - * Check attributes for eg. password Argon |
|
| 140 | - * |
|
| 141 | - * @return array |
|
| 142 | - */ |
|
| 139 | + * Check attributes for eg. password Argon |
|
| 140 | + * |
|
| 141 | + * @return array |
|
| 142 | + */ |
|
| 143 | 143 | protected static function getOptions() |
| 144 | 144 | {
|
| 145 | 145 | return isset(static::$memory) ? static::hashel() : static::options(); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
| 149 | - * Generate default values if attributes exist |
|
| 150 | - * eg. Password Argon |
|
| 151 | - * |
|
| 152 | - * @return array |
|
| 153 | - * |
|
| 154 | - */ |
|
| 149 | + * Generate default values if attributes exist |
|
| 150 | + * eg. Password Argon |
|
| 151 | + * |
|
| 152 | + * @return array |
|
| 153 | + * |
|
| 154 | + */ |
|
| 155 | 155 | protected static function hashel() |
| 156 | 156 | {
|
| 157 | 157 | return array_merge(static::$memory, static::$time, static::$thread); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
| 161 | - * Check the current attributes that use for compatible version |
|
| 162 | - * if doesn't set will return to default config |
|
| 163 | - * |
|
| 164 | - * @param string $hashmode |
|
| 165 | - * @param string $key |
|
| 166 | - * @return string |
|
| 167 | - */ |
|
| 161 | + * Check the current attributes that use for compatible version |
|
| 162 | + * if doesn't set will return to default config |
|
| 163 | + * |
|
| 164 | + * @param string $hashmode |
|
| 165 | + * @param string $key |
|
| 166 | + * @return string |
|
| 167 | + */ |
|
| 168 | 168 | public static function pwHash($hashmode, $key) |
| 169 | 169 | {
|
| 170 | 170 | $options = ($hashmode !== self::DEFAULT && version_compare(PHP_VERSION, '7.2.0', '>=')) ? static::getOptions() : static::getLength(); |
@@ -173,15 +173,15 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | - * Create new hashed with the old hashed password |
|
| 177 | - * and check for compatible php version |
|
| 178 | - * if match will produce new hashed |
|
| 179 | - * |
|
| 180 | - * @param string $hashmode |
|
| 181 | - * @param string $password |
|
| 182 | - * @param string $datahash |
|
| 183 | - * @return Moviet\Heavy\Exceptions\EqualsException |
|
| 184 | - */ |
|
| 176 | + * Create new hashed with the old hashed password |
|
| 177 | + * and check for compatible php version |
|
| 178 | + * if match will produce new hashed |
|
| 179 | + * |
|
| 180 | + * @param string $hashmode |
|
| 181 | + * @param string $password |
|
| 182 | + * @param string $datahash |
|
| 183 | + * @return Moviet\Heavy\Exceptions\EqualsException |
|
| 184 | + */ |
|
| 185 | 185 | public static function pwRehash($hashmode, $password, $datahash) |
| 186 | 186 | {
|
| 187 | 187 | $options = ($hashmode !== self::DEFAULT && version_compare(PHP_VERSION, '7.2.0', '>=')) ? static::getOptions() : static::getLength(); |
@@ -197,20 +197,20 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
| 200 | - * Generate default cost length |
|
| 201 | - * |
|
| 202 | - * @return array |
|
| 203 | - */ |
|
| 200 | + * Generate default cost length |
|
| 201 | + * |
|
| 202 | + * @return array |
|
| 203 | + */ |
|
| 204 | 204 | protected static function costLength() |
| 205 | 205 | {
|
| 206 | 206 | return [Verbal::DEFAULT_COST => Verbal::DEFAULT_COST_LENGTH]; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | - * Generate default memory, time, threads for password Argon |
|
| 211 | - * |
|
| 212 | - * @return array |
|
| 213 | - */ |
|
| 210 | + * Generate default memory, time, threads for password Argon |
|
| 211 | + * |
|
| 212 | + * @return array |
|
| 213 | + */ |
|
| 214 | 214 | protected static function options() |
| 215 | 215 | {
|
| 216 | 216 | return [Verbal::MEMORY_KEY => Verbal::DEFAULT_MEMORY_COST, Verbal::TIME_KEY => Verbal::DEFAULT_TIME_COST, |
@@ -218,23 +218,23 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | - * Generate password verification |
|
| 222 | - * |
|
| 223 | - * @param string $password |
|
| 224 | - * @param string $hash |
|
| 225 | - * @return bool |
|
| 226 | - */ |
|
| 221 | + * Generate password verification |
|
| 222 | + * |
|
| 223 | + * @param string $password |
|
| 224 | + * @param string $hash |
|
| 225 | + * @return bool |
|
| 226 | + */ |
|
| 227 | 227 | public static function pwTrust($password, $hash) |
| 228 | 228 | {
|
| 229 | 229 | return password_verify($password, $hash); |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | - * Generate password information |
|
| 234 | - * |
|
| 235 | - * @param string $hash |
|
| 236 | - * @return array |
|
| 237 | - */ |
|
| 233 | + * Generate password information |
|
| 234 | + * |
|
| 235 | + * @param string $hash |
|
| 236 | + * @return array |
|
| 237 | + */ |
|
| 238 | 238 | public static function pwInfo($hash) |
| 239 | 239 | {
|
| 240 | 240 | return password_get_info($hash); |
@@ -73,11 +73,11 @@ |
||
| 73 | 73 | const DEFAULT_THREAD_LENGTH = 6; |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | - * Generate password compatible suits |
|
| 77 | - * |
|
| 78 | - * @param string $algorithm |
|
| 79 | - * @return string |
|
| 80 | - */ |
|
| 76 | + * Generate password compatible suits |
|
| 77 | + * |
|
| 78 | + * @param string $algorithm |
|
| 79 | + * @return string |
|
| 80 | + */ |
|
| 81 | 81 | public static function hashAlgo($algorithm) |
| 82 | 82 | {
|
| 83 | 83 | switch ($algorithm) {
|
@@ -39,8 +39,8 @@ |
||
| 39 | 39 | protected static $auth; |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * @param string hash |
|
| 43 | - */ |
|
| 42 | + * @param string hash |
|
| 43 | + */ |
|
| 44 | 44 | protected static $hash; |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -356,7 +356,7 @@ |
||
| 356 | 356 | */ |
| 357 | 357 | protected static function calcKey() |
| 358 | 358 | {
|
| 359 | - return preg_replace('/[^0-9]/','', self::getMode());
|
|
| 359 | + return preg_replace('/[^0-9]/', '', self::getMode());
|
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |