Scenic v0.10.2 Scenic.Cache.Support.Hash View Source
Helper functions to work with hash signatures.
Both the Cache.File
and Cache.Term
modules use cryptographic hash signatures to verify that files are valid before using
the data they contain.
This modules provides a collection of helper functions that make it easy to use, generate and validate these hashes.
Any time one of these functions asks for a type of hash, the supported types are:
:sha
, :sha224
, :sha256
, :sha384
, :sha512
, and :ripemd160
Link to this section Summary
Functions
Calculate the hash of binary data
Calculate the hash of binary data
Verify that the given data conforms to the given hash
Verify that the given data conforms to the given hash
Verify that the data in a file conforms to the given hash
Verify that the data in a file conforms to the given hash
Link to this section Types
hash_type()
View Source
hash_type() :: :sha | :sha224 | :sha256 | :sha384 | :sha512 | :ripemd160
hash_type() :: :sha | :sha224 | :sha256 | :sha384 | :sha512 | :ripemd160
Link to this section Functions
binary(data, type) View Source
Calculate the hash of binary data
Returns the hash wrapped in a {:ok, hash}
tuple.
binary!(data, type) View Source
Calculate the hash of binary data
Returns the hash directly.
file(path, hash_type) View Source
file!(path, hash_type) View Source
verify(data, hash, hash_type) View Source
Verify that the given data conforms to the given hash.
If the verification passes, returns {:ok, data}
If it fails, returns {:error, :hash_failure}
verify!(data, hash, hash_type) View Source
Verify that the given data conforms to the given hash.
If the verification passes, returns the data unchanged. If it fails, raises an error
verify_file(path, hash, hash_type) View Source
Verify that the data in a file conforms to the given hash.
If the verification passes, returns {:ok, hash}
If it fails, returns {:error, :hash_failure}
verify_file!(path, hash, hash_type) View Source
Verify that the data in a file conforms to the given hash.
If the verification passes, returns the hash unchanged. If it fails, raises an error