Skip to main content

A library to generate and validate RFC6920 URIs

Project description

A library to generate and validate RFC6920 URIs

Naming Things with Hashes IETF RFC 6920 specifies both ni and nih schemes, and how they are generated and validated.

This library is composed by methods generate_ni (to generate a ni URI), generate_nih (to generate a nih URI), extract_digest (to get back both the digest and the hashing algorithm) and validate (to validate ni and nih URIs). Both generate_ni, generate_nih and validate understand both file paths and bytearray.

rfc6920.generate_nih(b'Hello World!') 
# It returns 'nih:sha-256;7f83-b165-7ff1-fc53-b92d-c181-48a1-d65d-fc2d-4b1f-a3d6-7728-4add-d200-126d-9069;d'

rfc6920.validate('nih:sha-256;7f83-b165-7ff1-fc53-b92d-c181-48a1-d65d-fc2d-4b1f-a3d6-7728-4add-d200-126d-9069;d', b'Hello World!')
# It returns True

rfc6920.validate('nih:sha-256;7f83-b165-7ff1-fc53-b92d-c181-48a1-d65d-fc2d-4b1f-a3d6-7728-4add-d200-126d-9069;e', b'Hello World!')
# It returns False, wrong check digit

rfc6920.validate('nih:sha-256;7f83-b165-7ff1-fc53-b92d-c181-48a1-d65d-fc2d-4b1f-a3d6-7728-4add-d200-126d-9069;d', b'Hello Mundo!')
# It returns False, different digest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rfc6920-0.2.2.tar.gz (14.4 kB view hashes)

Uploaded Source

Built Distribution

rfc6920-0.2.2-py3-none-any.whl (15.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page