Comments (8)
That's a good question. Also it would be nice, for those of us who don't speak crypto, to provide an example or two as to how this is supposed to be used, because even looking at the test file I have no idea as to how hmac is supposed to be called. Thanks !
from digestif.
Hi, you are true and I really would like to fix it but it's much more about build-system than this project. However, I think, from previous improvements needed by ocaml-git
, it's possible now to generate a documentation.
About hmac
, signature is:
val hmac: key:buffer -> buffer -> t
For any hash algorithm with Bytes.t
as input and output or Bigstring.t
as input and output. That means, if you want to generate a keyed-hash (SHA1), you should write:
# let hash = Digestif.SHA1.Bytes.hmac ~key:(Bytes.of_string "my-key") (Bytes.of_string "my-message");;
- Bytes.t
Then, you can use Digestif.SHA1.Bytes.to_hex
to have the hexadecimal representation of your hash. Finally, you can define a short-cut on top of your program like: module SHA1 = Digestif.SHA1.Bytes
precisely because Bytes.t
and Bigstring.t
are incompatible.
from digestif.
I see, and I assume that to check you just re-sign the message and then use compare on both signatures ? What are init, get and feed used for, just for my own curiosity ?
Thanks !
from digestif.
init
, get
and feed
are a couple of functions which need (or create) a state
to be used in an imperative context. In other words, digest : buffer -> t
(which produces a hash of your buffer) is implemented like this:
module SHA1 = Digestif.SHA1.Bytes
let digest content =
let state = SHA1.init () in
SHA1.feed state content;
SHA1.get state
This implementation is useful when you want to compute a data flow (and feed state
with each chunk of your flow). Then, you just need to use get
to ... get the final hash.
from digestif.
Updated by #39
from digestif.
Sorry, me again. Seems like this changed, and the doc in the README went away.
Is there any info about how to use the new version anywhere ? Thanks
Your site seems to be down
Digestif.SHA256.digest_bytes (Bytes.of_string s) |> Digestif.SHA256.to_hex
Error: Required module 'Digestif' is unavailable
from digestif.
See #49
from digestif.
The documentation exists here: https://mirage.github.io/digestif
from digestif.
Related Issues (20)
- Add a Continuous Integration to test little-endian/big-endian contexts HOT 2
- Better GADT
- Keccak
- Implement personalisation for Blake2 HOT 3
- Use `optint` on the `ocaml` backend.
- doc is broken HOT 2
- Make a release to include Keccak
- would be nice to have some @since in docs
- is this on opam?
- Build error while running `make deps` with mirage/mirage-www HOT 4
- lack of documentation HOT 2
- Provide polymorphic variant to describe which hash we use HOT 1
- Add `to_raw_bytes` HOT 2
- Feed a hmac HOT 3
- API usage and confusion HOT 1
- A way to stay comptatible with MirageOS HOT 1
- BLAKE3 HOT 1
- Test failure with alcotest 1.0.1 HOT 1
- Patch error installing with opam HOT 3
- Key of HMAC should be only a string HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from digestif.