--TEST-- Phar::setSupportedSignatures() with hash, zip-based --SKIPIF-- getSignature()); $p->setSignatureAlgorithm(Phar::MD5); copy($fname, $fname2); $p = new Phar($fname2); var_dump($p->getSignature()); $p->setSignatureAlgorithm(Phar::SHA1); copy($fname2, $fname3); $p = new Phar($fname3); var_dump($p->getSignature()); try { $p->setSignatureAlgorithm(Phar::SHA256); copy($fname3, $fname4); $p = new Phar($fname4); var_dump($p->getSignature()); } catch (Exception $e) { echo $e->getMessage(); } try { $p->setSignatureAlgorithm(Phar::SHA512); copy($fname4, $fname5); $p = new Phar($fname5); var_dump($p->getSignature()); } catch (Exception $e) { echo $e->getMessage(); } try { $config = __DIR__ . '/../files/openssl.cnf'; $config_arg = array('config' => $config); $keys=openssl_pkey_new($config_arg); openssl_pkey_export($keys, $privkey, NULL, $config_arg); $pubkey=openssl_pkey_get_details($keys); $p->setSignatureAlgorithm(Phar::OPENSSL, $privkey); copy($fname5, $fname6); file_put_contents($fname6 . '.pubkey', $pubkey['key']); $p = new Phar($fname6); var_dump($p->getSignature()); } catch (Exception $e) { echo $e->getMessage(); } ?> ===DONE=== --CLEAN-- --EXPECTF-- array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(5) "SHA-1" } array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(3) "MD5" } array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(5) "SHA-1" } array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-256" } array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-512" } array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "OpenSSL" } ===DONE===