named_information v1.0.1
named_information
A crystal lang implementation of rfc6920
Installation
-
Add the dependency to your
shard.yml
:dependencies: named_information: github: spider-gazelle/named_information
-
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
- Stephen von Takach - creator and maintainer
Repository
named_information
Owner
Statistic
- 0
- 0
- 0
- 1
- 1
- 9 months ago
- October 11, 2023
License
MIT License
Links
Synced at
Mon, 25 Nov 2024 03:24:25 GMT
Languages