Crystal Lang implemenation of Hashcash proof-of-work system.
-
Add the dependency to your
shard.yml
:dependencies: hashcash: github: place-labs/hashcash
-
Run
shards install
require "hashcash"
To generate a hashcash string:
Hashcash.generate("resource")
# => "1:20:201206222555:resource::pOWgc88+uDuefr/o:MTMxNzg2MA=="
To verify a hashcash string:
Hashcash.valid?("1:20:201206222555:resource::pOWgc88+uDuefr/o:MTMxNzg2MA==", "resource")
# => true
Hashcash.valid!("1:20:201206222555:resource::pOWgc88+uDuefr/o:MTMxNzg2MA==", "resource")
# => "1:20:201206222555:resource::pOWgc88+uDuefr/o:MTMxNzg2MA=="
# (or raises an exception if invalid)
- Fork it (https://github.com/your-github-user/hashcash/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Gab Fitzgerald - creator
- Caspian Baska - maintainer