pharext\Archive::getSignature PHP Method

getSignature() public method

public getSignature ( )
    function getSignature()
    {
        /* compatible with Phar::getSignature() */
        return ["hash_type" => self::$sigtyp[$this->signature["flags"]], "hash" => strtoupper(bin2hex($this->signature["hash"]))];
    }

Usage Example

Example #1
0
 /**
  * Retrieve metadata of the currently running phar
  * @param string $key
  * @return mixed
  */
 public function metadata($key = null)
 {
     if (extension_loaded("Phar")) {
         $running = new Phar(Phar::running(false));
     } else {
         $running = new Archive(PHAREXT_PHAR);
     }
     if ($key === "signature") {
         $sig = $running->getSignature();
         return sprintf("%s signature of %s\n%s", $sig["hash_type"], $this->metadata("name"), chunk_split($sig["hash"], 64, "\n"));
     }
     $metadata = $running->getMetadata();
     if (isset($key)) {
         return $metadata[$key];
     }
     return $metadata;
 }