Skip to content

Implements HashCash to prevent spammers abusing a resource.

License

Notifications You must be signed in to change notification settings

cachix/elm-hashcash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elm package

Implements HashCash in Elm to prevent spammers abusing a resource.

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:

import HashCash

let 
  data = "example data"
  difficulty = 3
  nonce = HashCash.findNonce difficulty data
in { nonce = nonce 
   , data = data
   }

Development

Install devenv and devenv shell elm-test.

About

Implements HashCash to prevent spammers abusing a resource.

Resources

License

Stars

Watchers

Forks

Packages

No packages published