@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function hash($password, $salt, $iterations) { |
114 | 114 | $len = strlen($password); |
115 | - $text = $password . '$apr1$' . $salt; |
|
115 | + $text = $password.'$apr1$'.$salt; |
|
116 | 116 | $bin = md5($password.$salt.$password, true); |
117 | 117 | for ($i = $len; $i > 0; $i -= 16) { |
118 | 118 | $text .= substr($bin, 0, min(16, $i)); |
@@ -143,23 +143,23 @@ discard block |
||
143 | 143 | protected function convertToHash($bin, $salt) { |
144 | 144 | $tmp = '$apr1$'.$salt.'$'; |
145 | 145 | $tmp .= $this->to64( |
146 | - (ord($bin[0])<<16) | (ord($bin[6])<<8) | ord($bin[12]), |
|
146 | + (ord($bin[0]) << 16) | (ord($bin[6]) << 8) | ord($bin[12]), |
|
147 | 147 | 4 |
148 | 148 | ); |
149 | 149 | $tmp .= $this->to64( |
150 | - (ord($bin[1])<<16) | (ord($bin[7])<<8) | ord($bin[13]), |
|
150 | + (ord($bin[1]) << 16) | (ord($bin[7]) << 8) | ord($bin[13]), |
|
151 | 151 | 4 |
152 | 152 | ); |
153 | 153 | $tmp .= $this->to64( |
154 | - (ord($bin[2])<<16) | (ord($bin[8])<<8) | ord($bin[14]), |
|
154 | + (ord($bin[2]) << 16) | (ord($bin[8]) << 8) | ord($bin[14]), |
|
155 | 155 | 4 |
156 | 156 | ); |
157 | 157 | $tmp .= $this->to64( |
158 | - (ord($bin[3])<<16) | (ord($bin[9])<<8) | ord($bin[15]), |
|
158 | + (ord($bin[3]) << 16) | (ord($bin[9]) << 8) | ord($bin[15]), |
|
159 | 159 | 4 |
160 | 160 | ); |
161 | 161 | $tmp .= $this->to64( |
162 | - (ord($bin[4])<<16) | (ord($bin[10])<<8) | ord($bin[5]), |
|
162 | + (ord($bin[4]) << 16) | (ord($bin[10]) << 8) | ord($bin[5]), |
|
163 | 163 | 4 |
164 | 164 | ); |
165 | 165 | $tmp .= $this->to64( |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if ($option == 'rounds') { |
82 | 82 | if ($value < 1000 || $value > 999999999) { |
83 | 83 | throw new \InvalidArgumentException( |
84 | - 'Invalid cost parameter specified, ' . |
|
84 | + 'Invalid cost parameter specified, '. |
|
85 | 85 | 'must be between 1000 and 999999999' |
86 | 86 | ); |
87 | 87 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | protected function generateSalt() { |
94 | 94 | $salt = parent::generateSalt(); |
95 | - return '$5$rounds=' . $this->options['rounds'] . '$' . $salt; |
|
95 | + return '$5$rounds='.$this->options['rounds'].'$'.$salt; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | } |
99 | 99 | \ No newline at end of file |
@@ -49,6 +49,6 @@ |
||
49 | 49 | |
50 | 50 | protected function generateSalt() { |
51 | 51 | $salt = parent::generateSalt(); |
52 | - return '$1$' . $salt; |
|
52 | + return '$1$'.$salt; |
|
53 | 53 | } |
54 | 54 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' |
77 | 77 | . '0123456789'; |
78 | 78 | $salt = $this->generator->generateString(32, $chars); |
79 | - $hash = md5($password . $salt); |
|
80 | - return $hash . ':' . $salt; |
|
79 | + $hash = md5($password.$salt); |
|
80 | + return $hash.':'.$salt; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | ); |
97 | 97 | } |
98 | 98 | list ($hash, $salt) = explode(':', $hash, 2); |
99 | - $test = md5($password . $salt); |
|
99 | + $test = md5($password.$salt); |
|
100 | 100 | return $this->compareStrings($test, $hash); |
101 | 101 | } |
102 | 102 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | if (!static::detect($hash)) { |
79 | 79 | throw new \InvalidArgumentException('Hash Not Created Here'); |
80 | 80 | } |
81 | - list(, , $iterations) = explode('$', $hash, 4); |
|
81 | + list(,, $iterations) = explode('$', $hash, 4); |
|
82 | 82 | return new static(array('cost' => $iterations)); |
83 | 83 | } |
84 | 84 | |
@@ -106,6 +106,6 @@ discard block |
||
106 | 106 | $salt = parent::generateSalt(); |
107 | 107 | $prefix = static::getPrefix(); |
108 | 108 | $prefix .= str_pad($this->options['cost'], 2, '0', STR_PAD_LEFT); |
109 | - return $prefix . '$' . $salt; |
|
109 | + return $prefix.'$'.$salt; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | \ No newline at end of file |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | public function create($password) { |
111 | 111 | $password = $this->checkPassword($password); |
112 | 112 | $size = $this->options['size'] - 8; // remove size of stored bits |
113 | - $saltSize = floor($size / 5); //Use 20% of the size for the salt |
|
113 | + $saltSize = floor($size / 5); //Use 20% of the size for the salt |
|
114 | 114 | $hashSize = $size - $saltSize; |
115 | 115 | $salt = $this->generator->generate($saltSize); |
116 | 116 | return $this->hash( |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | protected function hash($password, $salt, $iterations, $size) { |
160 | 160 | $bit = $this->options['kdf']->derive($password, $salt, $iterations, $size); |
161 | 161 | $sig = $this->options['kdf']->getSignature(); |
162 | - $sig = '$pbkdf$' . $sig . '$' . $iterations . '$' . $size; |
|
163 | - return $sig . '$' . base64_encode($salt) . '$' . base64_encode($bit); |
|
162 | + $sig = '$pbkdf$'.$sig.'$'.$iterations.'$'.$size; |
|
163 | + return $sig.'$'.base64_encode($salt).'$'.base64_encode($bit); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public function registerImplementation($name, $class) { |
99 | 99 | $this->registerType( |
100 | 100 | 'implementations', |
101 | - __NAMESPACE__ . '\\Password', |
|
101 | + __NAMESPACE__.'\\Password', |
|
102 | 102 | $name, |
103 | 103 | $class |
104 | 104 | ); |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function loadImplementations() { |
114 | 114 | $this->loadFiles( |
115 | - __DIR__ . '/Implementation', |
|
116 | - __NAMESPACE__ . '\\Implementation\\', |
|
115 | + __DIR__.'/Implementation', |
|
116 | + __NAMESPACE__.'\\Implementation\\', |
|
117 | 117 | array($this, 'registerImplementation') |
118 | 118 | ); |
119 | 119 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | namespace PasswordLib; |
20 | 20 | |
21 | -require_once __DIR__ . '/Core/AutoLoader.php'; |
|
21 | +require_once __DIR__.'/Core/AutoLoader.php'; |
|
22 | 22 | |
23 | 23 | $autoloader = new Core\AutoLoader(__NAMESPACE__, dirname(__DIR__)); |
24 | 24 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if (function_exists('posix_times')) { |
53 | 53 | $state .= serialize(posix_times()); |
54 | 54 | } |
55 | - $state .= getmypid() . memory_get_usage(); |
|
55 | + $state .= getmypid().memory_get_usage(); |
|
56 | 56 | $state .= serialize($_ENV); |
57 | 57 | $this->state = hash('sha512', $state, true); |
58 | 58 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function generate($size) { |
68 | 68 | $result = ''; |
69 | - $seed = microtime() . memory_get_usage(); |
|
70 | - $this->state = hash('sha512', $this->state . $seed, true); |
|
69 | + $seed = microtime().memory_get_usage(); |
|
70 | + $this->state = hash('sha512', $this->state.$seed, true); |
|
71 | 71 | /** |
72 | 72 | * Make the generated randomness a bit better by forcing a GC run which |
73 | 73 | * should complete in a indeterminate amount of time, hence improving |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | gc_collect_cycles(); |
78 | 78 | for ($i = 0; $i < $size; $i += 8) { |
79 | - $seed = $this->state . microtime() . pack('N', $i); |
|
79 | + $seed = $this->state.microtime().pack('N', $i); |
|
80 | 80 | $this->state = hash('sha512', $seed, true); |
81 | 81 | /** |
82 | 82 | * We only use the first 8 bytes here to prevent exposing the state |