Skip to content

A crystal lang implementation of rfc6920 (Naming Things with Hashes)

License

Notifications You must be signed in to change notification settings

spider-gazelle/named_information

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

named_information

A crystal lang implementation of rfc6920

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      named_information:
        github: spider-gazelle/named_information
  2. Run shards install

Usage

basic usage

require "named_information"

NamedInformation.generate_uri("Hello World!") #=> "ni:///sha-256;f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk"

hash = NamedInformation::Hash.new "ni://example.com/sha-256;f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk"
hash.matches?("Hello World!") # => true
hash.authority # => "example.com"
hash.algorithm # => "sha-256"

other_hash = NamedInformation::Hash.new "sha-256;f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk"

hash == other_hash # => true

Works with binary data

require "named_information"

hash = NamedInformation::Hash.new(bytes)
hash.to_slice

hash = NamedInformation::Hash.new(uint128)
hash.to_u128

Contributors

About

A crystal lang implementation of rfc6920 (Naming Things with Hashes)

Resources

License

Stars

Watchers

Forks

Packages

No packages published