From f0b87aee28d16eb636ea68869b598ed83e48b9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Mon, 19 Feb 2024 07:34:08 +0000 Subject: [PATCH] README: revamp --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b822d32..33fcb70 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,28 @@ +![Elm package](https://img.shields.io/elm-package/v/cachix/elm-hashcash) + Implements [HashCash](https://en.wikipedia.org/wiki/Hashcash) in Elm to prevent spammers abusing a resource. -[Install devenv](https://devenv.sh/getting-started/) and `devenv shell`. \ No newline at end of file +HashCash hashes your data with a `sha256` and appends a nonce. + +It then verifies that the hash has N number of leading zeros, which is the difficulty level. + +If it doesn't match, it increases the nonce by 1 and retries. + +The more leading zeros you want, the longer it takes to find the hash. + +Here's an example how to calculate the nonce and send it over with the data: + +```elm +let + data = "example data" + difficulty = 3 + nonce = findNonce difficulty data +in { nonce = nonce + , data = data + } +``` + +### Development + +[Install devenv](https://devenv.sh/getting-started/) and `devenv shell elm-test`. \ No newline at end of file