module Hashcash

Defined in:

hashcash.cr
hashcash/error.cr
hashcash/stamp.cr

Class Method Summary

Class Method Detail

def self.generate(resource : String, version = "1", bits = Stamp::DEFAULT_BITS, date = Time.utc, ext = "") : String #
Hashcash.generate("resource")
# => "1:20:201206222555:resource::pOWgc88+uDuefr/o:MTMxNzg2MA=="

# or, can customise hashcash defaults
Hashcash.generate("hello", version: 1, bits: 16, date: Time.utc, ext: "goodbyye")
# => "1:16:201206222403:hello:goodbyye:kfwaGRadlD3ddc9G:MTMxMzY5NQ=="

[View source]
def self.valid!(stamp_string : String, resource : String, time_window = Stamp.default_time_window, bits = Stamp::DEFAULT_BITS) : String #
Hashcash.valid!("1:20:201206222555:resource::pOWgc88+uDuefr/o:MTMxNzg2MA==", "resource")
# => "1:20:201206222555:resource::pOWgc88+uDuefr/o:MTMxNzg2MA=="
Hashcash.valid?("invalid_string", "resource")
# raises Hashcash::Error

[View source]
def self.valid?(stamp_string : String, resource : String, time_window = Stamp.default_time_window, bits = Stamp::DEFAULT_BITS) : Bool #
Hashcash.valid?("1:20:201206222555:resource::pOWgc88+uDuefr/o:MTMxNzg2MA==", "resource")
# => true
Hashcash.valid?("invalid_string", "resource")
# => false

[View source]