Esempio n. 1
0
 /**
  * Encodes the HMAC based on the values that have been entered using the hash() function
  *
  * @throws HmacInvalidArgumentException
  * @return AbstractAdapter
  */
 public function encode()
 {
     if (!$this->entity->isEncodable()) {
         throw new HmacInvalidArgumentException('The item is not encodable, make sure the key, time and data are set');
     }
     $firstHash = $this->hash($this->entity->getData(), $this->entity->getTime(), $this->noFirstHashIterations);
     $secondHash = $this->hash($this->entity->getKey(), '', $this->noSecondHashIterations);
     $this->entity->setHmac($this->hash($firstHash, $secondHash, $this->noFinalHashIterations));
     return $this;
 }
Esempio n. 2
0
 /**
  * Testing the toArray method
  */
 public function testToArray()
 {
     $array = $this->getDummyHmacData();
     $this->assertFalse($this->entity->toArray());
     $this->entity->setData($array['data']);
     $this->entity->setHmac($array['hmac']);
     $this->entity->setTime($array['time']);
     unset($array['key']);
     $this->assertSame($array, $this->entity->toArray());
 }
Esempio n. 3
0
 /**
  * Returns the entity array or false if the hmac doesn't exist
  *
  * @return array
  */
 public function toArray()
 {
     return $this->entity->toArray();
 }