Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

Latest commit

 

History

History
78 lines (47 loc) · 1.79 KB

zend.validator.file.sha1.rst

File metadata and controls

78 lines (47 loc) · 1.79 KB
orphan

Sha1

Zend\Validator\File\Sha1 allows you to validate if a given file's hashed contents matches the supplied sha1 hash(es). It is subclassed from the Hash validator <zend.validator.file.hash> to provide a convenient validator that only supports the sha1 algorithm.

Note

This validator requires the Hash extension from PHP with the sha1 algorithm.

Supported Options

The following set of options are supported:

  • hash (string)

    Hash to test the file against.

Usage Examples

// Does file have the given hash?
$validator = new \Zend\Validator\File\Sha1('3b3652f336522365223');

// Or, check file against multiple hashes
$validator = new \Zend\Validator\File\Sha1(array(
    '3b3652f336522365223', 'eb3365f3365ddc65365'
));

// Perform validation with file path
if ($validator->isValid('./myfile.txt')) {
    // file is valid
}

Public Methods

getSha1()

Returns the current set of sha1 hashes.

rtype

array

addSha1(string|array $options)

Adds a sha1 hash for one or multiple files to the internal set of hashes.

param $options

See Supported Options <zend.validator.file.sha1.options> section for more information.

setSha1(string|array $options)

Sets a sha1 hash for one or multiple files. Removes any previously set hashes.

param $options

See Supported Options <zend.validator.file.sha1.options> section for more information.