@@ -83,28 +83,28 @@ |
||
83 | 83 | public function truePasswordProvider() |
84 | 84 | { |
85 | 85 | return array( |
86 | - ['password',\password_hash('password', PASSWORD_DEFAULT)], |
|
87 | - ['foobar',\password_hash('foobar', PASSWORD_DEFAULT)], |
|
88 | - ['234234234cookie',\password_hash('234234234cookie', PASSWORD_DEFAULT)], |
|
89 | - ['fobatraz56278',\password_hash('fobatraz56278', PASSWORD_DEFAULT)], |
|
90 | - ['foo__fgg__bat__789',\password_hash('foo__fgg__bat__789', PASSWORD_DEFAULT)], |
|
91 | - ['passwdsasdads2123ord',\password_hash('passwdsasdads2123ord', PASSWORD_DEFAULT)] |
|
86 | + ['password', \password_hash('password', PASSWORD_DEFAULT)], |
|
87 | + ['foobar', \password_hash('foobar', PASSWORD_DEFAULT)], |
|
88 | + ['234234234cookie', \password_hash('234234234cookie', PASSWORD_DEFAULT)], |
|
89 | + ['fobatraz56278', \password_hash('fobatraz56278', PASSWORD_DEFAULT)], |
|
90 | + ['foo__fgg__bat__789', \password_hash('foo__fgg__bat__789', PASSWORD_DEFAULT)], |
|
91 | + ['passwdsasdads2123ord', \password_hash('passwdsasdads2123ord', PASSWORD_DEFAULT)] |
|
92 | 92 | ); |
93 | 93 | } |
94 | 94 | |
95 | 95 | public function falsePasswordProvider() |
96 | 96 | { |
97 | 97 | return array( |
98 | - ['password','$2y$10$rUHpBM6hi0TyCBIgGnJYAuBPLe66sadkE.RW'], |
|
99 | - ['password','cGFzc3dvcmQ='], |
|
100 | - ['password','5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'], |
|
101 | - ['password','5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8'], |
|
102 | - ['password','74dfc2b27acfa364da55f93a5caee29ccad3557247eda238831b3e9bd931b01d77fe994e4f12b9d4cfa92a124461d2065197d8cf7f33fc88566da2db2a4d6eae'], |
|
103 | - ['password','db4d9992897eda89b50f1d3208db607902da7e79c6f3bc6e6933cc5919068564'], |
|
104 | - ['password','35c246d5'], |
|
105 | - ['password','ycbTFtbcTZUqeJ/UuIWO1w=='], |
|
106 | - ['password','c9c6d316d6dc4d952a789fd4b8858ed7'], |
|
107 | - ['password','c9:c6:d3:16:d6:dc:4d:95:2a:78:9f:d4:b8:85:8e:d7'], |
|
98 | + ['password', '$2y$10$rUHpBM6hi0TyCBIgGnJYAuBPLe66sadkE.RW'], |
|
99 | + ['password', 'cGFzc3dvcmQ='], |
|
100 | + ['password', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'], |
|
101 | + ['password', '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8'], |
|
102 | + ['password', '74dfc2b27acfa364da55f93a5caee29ccad3557247eda238831b3e9bd931b01d77fe994e4f12b9d4cfa92a124461d2065197d8cf7f33fc88566da2db2a4d6eae'], |
|
103 | + ['password', 'db4d9992897eda89b50f1d3208db607902da7e79c6f3bc6e6933cc5919068564'], |
|
104 | + ['password', '35c246d5'], |
|
105 | + ['password', 'ycbTFtbcTZUqeJ/UuIWO1w=='], |
|
106 | + ['password', 'c9c6d316d6dc4d952a789fd4b8858ed7'], |
|
107 | + ['password', 'c9:c6:d3:16:d6:dc:4d:95:2a:78:9f:d4:b8:85:8e:d7'], |
|
108 | 108 | ); |
109 | 109 | } |
110 | 110 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param array $payload |
59 | 59 | * @return string |
60 | 60 | */ |
61 | - public function create(array $payload = []){ |
|
61 | + public function create(array $payload = []) { |
|
62 | 62 | $hash = $this->generate($this->algorithm, $payload, $this->privateKey); |
63 | 63 | return base64_encode($this->algorithm.'='.$hash); |
64 | 64 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $decodedHash = base64_decode($encodedHash); |
94 | 94 | |
95 | - list($algo, $hash) = array_pad( explode('=', $decodedHash), 4, $this->algorithm); |
|
95 | + list($algo, $hash) = array_pad(explode('=', $decodedHash), 4, $this->algorithm); |
|
96 | 96 | |
97 | 97 | $payloadHash = $this->generate($this->algorithm, $payload, $this->privateKey); |
98 | 98 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return array |
151 | 151 | */ |
152 | - public function getPayload(){ |
|
152 | + public function getPayload() { |
|
153 | 153 | return $this->payload; |
154 | 154 | } |
155 | 155 |
@@ -67,7 +67,9 @@ |
||
67 | 67 | * Internal Function to creates hash from payload. |
68 | 68 | * |
69 | 69 | * @param array $payload |
70 | - * @return mixed |
|
70 | + * @param string $algorithm |
|
71 | + * @param string $privateKey |
|
72 | + * @return string |
|
71 | 73 | */ |
72 | 74 | private function generate($algorithm, array $payload = [], $privateKey) |
73 | 75 | { |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | $this->data = ['foo' => 'bar']; |
33 | 33 | $this->privateKey = 'privateKey'; |
34 | 34 | |
35 | - $this->hmac = new HashHmac($this->privateKey,$this->algo); |
|
35 | + $this->hmac = new HashHmac($this->privateKey, $this->algo); |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function testHash() |
40 | 40 | { |
41 | 41 | $actual = $this->hmac->create($this->data); |
42 | - $expected = hash_hmac($this->algo, json_encode($this->data) , $this->privateKey); |
|
42 | + $expected = hash_hmac($this->algo, json_encode($this->data), $this->privateKey); |
|
43 | 43 | $result = $this->hmac->verify($actual, $expected); |
44 | 44 | $this->assertEquals(true, $result); |
45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function testCompareHash() |
48 | 48 | { |
49 | 49 | $encodedHash = $this->hmac->create($this->data); |
50 | - $this->assertEquals(true, $this->auth->verify($encodedHash,$this->data)); |
|
50 | + $this->assertEquals(true, $this->auth->verify($encodedHash, $this->data)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | public function testCompareHashInvalidAlgo() |