コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getHash($returnBinaryForm = false)
 {
     if (!$this->hash) {
         $this->hashRaw = hash_final($this->context, true);
         $this->hash = HashUtils::binToHex($this->hashRaw);
         $this->context = null;
     }
     return $returnBinaryForm ? $this->hashRaw : $this->hash;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function getHash($returnBinaryForm = false)
 {
     if (!$this->hash) {
         // Perform hashes up the tree to arrive at the root checksum of the tree hash
         $hashes = $this->checksums;
         while (count($hashes) > 1) {
             $sets = array_chunk($hashes, 2);
             $hashes = array();
             foreach ($sets as $set) {
                 $hashes[] = count($set) === 1 ? $set[0] : hash($this->algorithm, $set[0] . $set[1], true);
             }
         }
         $this->hashRaw = $hashes[0];
         $this->hash = HashUtils::binToHex($this->hashRaw);
     }
     return $returnBinaryForm ? $this->hashRaw : $this->hash;
 }