Scenic.Cache.Support.Hash (Scenic v0.10.3) 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
Compute hash for the given file
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
Specs
hash_type() :: :sha | :sha224 | :sha256 | :sha384 | :sha512 | :ripemd160
Link to this section Functions
Specs
Calculate the hash of binary data
Returns the hash wrapped in a {:ok, hash}
tuple.
Specs
Calculate the hash of binary data
Returns the hash directly.
Compute hash for the given file
Specs
Specs
Specs
verify(data :: binary(), hash :: bitstring(), type :: hash_type()) :: {:ok, binary()} | {:error, :hash_failure}
Verify that the given data conforms to the given hash.
If the verification passes, returns {:ok, data}
If it fails, returns {:error, :hash_failure}
Specs
Verify that the given data conforms to the given hash.
If the verification passes, returns the data unchanged. If it fails, raises an error
Specs
verify_file(path :: bitstring(), hash :: bitstring(), type :: hash_type()) :: {:ok, binary()} | {:error, :hash_failure}
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}
Specs
verify_file!(path :: bitstring(), hash :: bitstring(), type :: hash_type()) :: binary() | no_return()
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