<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.phar.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'phar.setsignaturealgorithm.php',
    1 => 'Phar::setSignatureAlgorithm',
    2 => 'Set the signature algorithm for a phar and apply it',
  ),
  'up' => 
  array (
    0 => 'class.phar.php',
    1 => 'Phar',
  ),
  'prev' => 
  array (
    0 => 'phar.setmetadata.php',
    1 => 'Phar::setMetadata',
  ),
  'next' => 
  array (
    0 => 'phar.setstub.php',
    1 => 'Phar::setStub',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/phar/Phar/setSignatureAlgorithm.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="phar.setsignaturealgorithm" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Phar::setSignatureAlgorithm</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL phar &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">Phar::setSignatureAlgorithm</span> &mdash; <span class="dc-title">Set the signature algorithm for a phar and apply it</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-phar.setsignaturealgorithm-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Phar::setSignatureAlgorithm</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$algo</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$privateKey</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

  <blockquote class="note"><p><strong class="note">Nota</strong>: <p class="para">This
method requires the <var class="filename">php.ini</var> setting <code class="literal">phar.readonly</code> to be
set to <code class="literal">0</code> in order to work for <span class="classname"><a href="class.phar.php" class="classname">Phar</a></span>
objects.  Otherwise, a <span class="classname"><a href="class.pharexception.php" class="classname">PharException</a></span> will be thrown.</p></p></blockquote>

  <p class="para">
   set the signature algorithm for a phar and apply it.  The
   signature algorithm must be one of <code class="literal">Phar::MD5</code>,
   <code class="literal">Phar::SHA1</code>, <code class="literal">Phar::SHA256</code>,
   <code class="literal">Phar::SHA512</code>, or <code class="literal">Phar::OPENSSL</code>.
  </p>
  <p class="para">
   Note that all executable phar archives have a signature created
   automatically, <code class="literal">SHA1</code> by default.  data tar- or zip-based archives
   (archives created with the <span class="classname"><a href="class.phardata.php" class="classname">PharData</a></span> class) must have
   their signature created and set explicitly via
   <span class="function"><strong>Phar::setSignatureAlgorithm()</strong></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-phar.setsignaturealgorithm-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">algo</code></dt>
     <dd>
      <p class="para">
       One of <code class="literal">Phar::MD5</code>,
   <code class="literal">Phar::SHA1</code>, <code class="literal">Phar::SHA256</code>,
   <code class="literal">Phar::SHA512</code>, or <code class="literal">Phar::OPENSSL</code>
      </p>
     </dd>
    
    
     <dt><code class="parameter">privateKey</code></dt>
     <dd>
      <p class="para">
       The contents of an OpenSSL private key, as extracted from a certificate or
       OpenSSL key file:
       <div class="example-contents">
        <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$private </span><span style="color: #007700">= </span><span style="color: #0000BB">openssl_get_privatekey</span><span style="color: #007700">(</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'private.pem'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$pkey </span><span style="color: #007700">= </span><span style="color: #DD0000">''</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">openssl_pkey_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$private</span><span style="color: #007700">, </span><span style="color: #0000BB">$pkey</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setSignatureAlgorithm</span><span style="color: #007700">(</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">OPENSSL</span><span style="color: #007700">, </span><span style="color: #0000BB">$pkey</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
       </div>

       See <a href="phar.using.php" class="link">phar introduction</a> for instructions on
       naming and placement of the public key file.
      </p>
     </dd>
    
   </dl>
  </p>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-phar.setsignaturealgorithm-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Nessun valore viene restituito.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phar.setsignaturealgorithm-errors">
  <h3 class="title">Errori/Eccezioni</h3>
  <p class="para">
   Throws <span class="classname"><a href="class.unexpectedvalueexception.php" class="classname">UnexpectedValueException</a></span> for many errors,
   and a <span class="classname"><a href="class.pharexception.php" class="classname">PharException</a></span>
   if any problems occur flushing changes to disk.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-phar.setsignaturealgorithm-changelog">
  <h3 class="title">Log delle modifiche</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versione</th>
      <th>Descrizione</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">privateKey</code> is now nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>

 
 <div class="refsect1 seealso" id="refsect1-phar.setsignaturealgorithm-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="phar.getsupportedsignatures.php" class="function" rel="rdfs-seeAlso">Phar::getSupportedSignatures()</a> - Return array of supported signature types</span></li>
    <li><span class="function"><a href="phar.getsignature.php" class="function" rel="rdfs-seeAlso">Phar::getSignature()</a> - Return MD5/SHA1/SHA256/SHA512/OpenSSL signature of a Phar archive</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>