Crc32

Zend\Validator\File\Crc32 allows you to validate if a given file’s hashed contents matches the supplied crc32 hash(es). It is subclassed from the Hash validator to provide a convenient validator that only supports the crc32 algorithm.

Note

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

Supported Options

The following set of options are supported:

  • hash (string)

    Hash to test the file against.

Usage Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// Does file have the given hash?
$validator = new \Zend\Validator\File\Crc32('3b3652f');

// Or, check file against multiple hashes
$validator = new \Zend\Validator\File\Crc32(array('3b3652f', 'e612b69'));

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

Public Methods

getCrc32()

Returns the current set of crc32 hashes.

Return type:array
addCrc32(string|array $options)

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

Parameters:$options – See Supported Options section for more information.
setCrc32(string|array $options)

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

Parameters:$options – See Supported Options section for more information.
blog comments powered by Disqus