downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

PharData::setStub> <Phar::setMetadata
[edit] Last updated: Fri, 17 May 2013

view this page in

Phar::setSignatureAlgorithm

(PHP >= 5.3.0, PECL phar >= 1.1.0)

Phar::setSignatureAlgorithmEstablecer el algoritmo de firma para un phar y aplicarlo

Descripción

void Phar::setSignatureAlgorithm ( int $sigtype )

Nota:

Este método requiere que la opción de php.ini phar.readonly esté establecida a 0 para que trabaje con objetos Phar. De otra manera, se lanzará una excepción de tipo PharException.

Establece el algoritmo de firma para un phar y lo aplica. El algoritmo de firma debe ser una de las constantes Phar::MD5, Phar::SHA1, Phar::SHA256, Phar::SHA512, o Phar::OPENSSL. (PGP aún no está soportado y se recurre a SHA-1).

Parámetros

sigtype

Una de las constantes Phar::MD5, Phar::SHA1, Phar::SHA256, Phar::SHA512, or Phar::PGP

Valores devueltos

No devuelve ningún valor.

Errores/Excepciones

Lanza una excepción de tipo UnexpectedValueException para muchos errores, una excepción de tipo BadMethodCallException si se llamó para un archivo basao en zip o en tar, y una excepción de tipo PharException si ocurrió algún problema al volcar los cambios al disco.

Ver también



add a note add a note User Contributed Notes Phar::setSignatureAlgorithm - [1 notes]
up
0
obsidian[at-nospam]codebite[dot]net
1 year ago
As a note, the docs don't show the (optional) second parameter nor mention the existence of the Phar::OPENSSL class constant also available for use with this method.

To sign a phar with OpenSSL, for example...

<?php

$phar
= new Phar('somephar.phar');
// ... add your files and such
$phar->setSignatureAlgorithm(Phar::OPENSSL, file_get_contents('private_key_here.pem'));
// ... do whatever else you want afterwards here ...
?>

Hope this proves useful to someone.

 
show source | credits | sitemap | contact | advertising | mirror sites