{"id":17723549,"url":"https://github.com/doriantaylor/rb-uri-ni","last_synced_at":"2025-03-14T05:32:00.083Z","repository":{"id":59158775,"uuid":"230885264","full_name":"doriantaylor/rb-uri-ni","owner":"doriantaylor","description":"RFC 6920 ni:/// URI handler","archived":false,"fork":false,"pushed_at":"2020-03-18T05:13:13.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-08T17:30:11.641Z","etag":null,"topics":["rfc-6920","ruby","uri"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doriantaylor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-30T09:16:26.000Z","updated_at":"2021-02-01T11:35:05.000Z","dependencies_parsed_at":"2022-09-13T20:10:24.285Z","dependency_job_id":null,"html_url":"https://github.com/doriantaylor/rb-uri-ni","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doriantaylor%2Frb-uri-ni","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doriantaylor%2Frb-uri-ni/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doriantaylor%2Frb-uri-ni/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doriantaylor%2Frb-uri-ni/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doriantaylor","download_url":"https://codeload.github.com/doriantaylor/rb-uri-ni/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243532517,"owners_count":20306151,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rfc-6920","ruby","uri"],"created_at":"2024-10-25T15:43:20.844Z","updated_at":"2025-03-14T05:31:59.653Z","avatar_url":"https://github.com/doriantaylor.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# URI::NI - RFC6920 Named Identifiers\n\nThis module implements the `ni:` URI scheme from [RFC\n6920](https://tools.ietf.org/html/rfc6920).\n\n```ruby\nrequire 'uri'\nrequire 'uri-ni' # or 'uri/ni', if you prefer\n\nni = URI::NI.compute 'some data'\n# =\u003e #\u003cURI::NI ni:///sha-256;EweZDmulyhRes16ZGCqb7EZTG8VN32VqYCx4D6AkDe4\u003e\nni.hexdigest\n# =\u003e \"1307990e6ba5ca145eb35e99182a9bec46531bc54ddf656a602c780fa0240dee\"\n```\n\nThis of course corresponds to:\n\n```bash\n$ echo -n some data | sha256sum\n1307990e6ba5ca145eb35e99182a9bec46531bc54ddf656a602c780fa0240dee  -\n```\n\nThis works as expected:\n\n```ruby\nni = URI('ni:///sha-256;4wwup6dvg7fBqXXdwkKGtnXnFOu7xyzNXwQBcwIxq1c')\n# =\u003e #\u003cURI::NI ni:///sha-256;4wwup6dvg7fBqXXdwkKGtnXnFOu7xyzNXwQBcwIxq1c\u003e\n```\n\nRFC 6920 [specifies a\nregistry](https://www.iana.org/assignments/named-information/named-information.xhtml)\nfor algorithm designators. Of that list, `sha-256`, `sha-384` and\n`sha-512` are implemented. Eventually I will get around to doing the\nSHA-3 digests as well as the truncated SHA-256 ones. Implemented but\n_not_ in the registry are `md5`, `sha-1` and `rmd-160`. Really these\nidentifiers only matter when you are trying to `compute` a new\ndigest. For instance you can do this:\n\n```ruby\nni = URI('ni:///lol;wut')\n# =\u003e #\u003cURI::NI ni:///lol;wut\u003e\n```\n\n…and the parser won't complain. But, if you then tried to take this\nresult and compute a new digest with it:\n\n```ruby\nni\n# =\u003e #\u003cURI::NI ni:///lol;wut\u003e\nni.compute 'derp'\n# URI::InvalidComponentError: Can't resolve a Digest context for the algorithm lol.\n```\n\nThe purpose of this configuration is so that the parser doesn't croak\non unexpected input, but otherwise assumes you know what you're\ndoing. As such, there is no attempt to measure or otherwise divine the\nrepresentation of any updates to the `digest` component:\n\n```ruby\nni = URI::NI.compute 'some data'\n# =\u003e #\u003cURI::NI ni:///sha-256;EweZDmulyhRes16ZGCqb7EZTG8VN32VqYCx4D6AkDe4\u003e\nni.digest = 'whatever'\n# =\u003e \"whatever\"\nni\n# =\u003e #\u003cURI::NI ni:///sha-256;d2hhdGV2ZXI\u003e\n```\n\nIn addition to computing new digest URIs, this module will return the\ninteresting part of its contents in binary, hexadecimal, base64, and\n(with a soft dependency), [base32](https://rubygems.org/gems/base32).\nThere are accessors and mutators for `digest`, `hexdigest`,\n`b32digest`, and `b64digest`.\n\nFinally, this module will also reuse any extant `Digest::Instance`\nobject as long as it is in the inventory, and furthermore the\n`compute` method takes a block:\n\n```ruby\nctx = Digest::SHA256.new\n# =\u003e #\u003cDigest::SHA256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\u003e\nctx \u003c\u003c 'hello world'\n# =\u003e #\u003cDigest::SHA256: b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9\u003e\nni = URI::NI.compute ctx\n# =\u003e #\u003cURI::NI ni:///sha-256;uU0nuZNNPgilLlLX2n2r-sSE7-N6U4DukIj3rOLvzek\u003e\nni.hexdigest\n# =\u003e \"b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9\"\nni = URI::NI.compute do |ctx|\n  ctx \u003c\u003c 'hello world'\nend\n# =\u003e #\u003cURI::NI ni:///sha-256;uU0nuZNNPgilLlLX2n2r-sSE7-N6U4DukIj3rOLvzek\u003e\n```\n\n## Documentation\n\nGenerated and deposited [in the usual\nplace](http://www.rubydoc.info/github/doriantaylor/rb-uri-ni/master).\n\n## Installation\n\nYou know how to do this:\n\n    $ gem install uri-ni\n\nOr, [download it off rubygems.org](https://rubygems.org/gems/uri-ni).\n\n## Contributing\n\nBug reports and pull requests are welcome at\n[the GitHub repository](https://github.com/doriantaylor/rb-uri-ni).\n\n## Copyright \u0026 License\n\n©2019 [Dorian Taylor](https://doriantaylor.com/)\n\nThis software is provided under\nthe [Apache License, 2.0](https://www.apache.org/licenses/LICENSE-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoriantaylor%2Frb-uri-ni","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoriantaylor%2Frb-uri-ni","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoriantaylor%2Frb-uri-ni/lists"}