zendframework/zend-validator
Powerful validation library from Zend Framework for PHP apps. Provides a wide range of reusable validators, input filtering, and custom rule support with clear error messages. Integrates easily into forms and domain validation workflows.
Zend\Validator\File\Hash allows you to validate if a given file's hashed
contents matches the supplied hash(es) and algorithm(s).
Requires the hash extension
This validator requires the PHP Hash extension. A list of supported hash algorithms can be found with the hash_algos() function.
The following set of options are supported:
hash: String hash or array of hashes against which to test.algorithm: String hashing algorithm to use; defaults to crc32use Zend\Validator\File\Hash;
// Does file have the given hash?
$validator = new Hash('3b3652f', 'crc32');
// Or, check file against multiple hashes
$validator = new Hash(['3b3652f', 'e612b69'], 'crc32');
// Or use options notation:
$validator = new Hash([
'hash' => ['3b3652f', 'e612b69'],
'algorithm' => 'crc32',
]);
// Perform validation with file path
if ($validator->isValid('./myfile.txt')) {
// file is valid
}
getHash() : array
Returns an array containing the set of hashes against which to validate.
addHash(string|array $options) : void
Add one or more hashes against which to validate.
setHash(string|array $options) : void
Overwrite the current set of hashes with those provided to the method.
How can I help you explore Laravel packages today?