https://github.com/pepicrft/digester
An Elixir utility to obtain a digest from various Elixir primities
https://github.com/pepicrft/digester
digest elixir hashing
Last synced: 5 months ago
JSON representation
An Elixir utility to obtain a digest from various Elixir primities
- Host: GitHub
- URL: https://github.com/pepicrft/digester
- Owner: pepicrft
- License: mit
- Created: 2025-03-23T10:02:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-01-14T13:53:59.000Z (5 months ago)
- Last Synced: 2026-01-14T17:35:44.152Z (5 months ago)
- Language: Elixir
- Size: 55.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Digester
[]()
[]()
[]()
[]()
[](https://opensource.org/licenses/MIT)
`Digester` provides a set of utilities for obtaining **digests** from Elixir primitives. Digests are useful to determine if a value has changed, for example, in a cache.
## Installation
The package can be installed by adding `digester` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:digester, "~> 0.2.0"}
]
end
```
## Usage
To obtain a digest from a value or a set of values, you'll have to first create an instance of `Digester`:
```elixir
digester = Digester.new() # Defaults to the SHA256 algorithm
# You can specify the algorithm to use
digester = Digester.new(:sha256)
```
Then, you can use `Digester.combine/2` for every value you'd like to include in the digest:
```elixir
digester = digester
|> Digester.combine("foo")
|> Digester.combine(%{bar: "baz"})
```
Remember that **the order** in which you combine values matters, so the following will produce a different digest:
```elixir
digester = digester
|> Digester.combine(%{bar: "baz"})
|> Digester.combine("foo")
```
Finally, you can obtain the digest by calling `Digester.finalize/1`:
```elixir
digest = Digester.finalize(digester)
```
`digest` will be a `String` containing the digest of the values you combined.