Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spider-gazelle/named_information
A crystal lang implementation of rfc6920 (Naming Things with Hashes)
https://github.com/spider-gazelle/named_information
Last synced: 25 days ago
JSON representation
A crystal lang implementation of rfc6920 (Naming Things with Hashes)
- Host: GitHub
- URL: https://github.com/spider-gazelle/named_information
- Owner: spider-gazelle
- License: mit
- Created: 2023-10-11T09:05:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-02T03:37:36.000Z (11 months ago)
- Last Synced: 2024-08-04T01:03:17.486Z (4 months ago)
- Language: Crystal
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - named_information - Naming Things with Hashes [rfc6920](https://datatracker.ietf.org/doc/html/rfc6920) (Algorithms and Data structures)
README
# named_information
A crystal lang implementation of [rfc6920](https://datatracker.ietf.org/doc/html/rfc6920)
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
named_information:
github: spider-gazelle/named_information
```2. Run `shards install`
## Usage
basic usage
```crystal
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
```crystal
require "named_information"hash = NamedInformation::Hash.new(bytes)
hash.to_slicehash = NamedInformation::Hash.new(uint128)
hash.to_u128
```## Contributors
- [Stephen von Takach](https://github.com/stakach) - creator and maintainer