Skip to main content

Create and parse HTML subresource integrity values

Project description

A Python package to create and parse subresource integrity values

Usage

>>> import subresource_integrity as integrity
>>> data = b"alert('Hello, world.');"
>>> integrity.render(data)
'sha384-H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO'

>>> hashes = list(integrity.generate(data, ['sha384', 'sha256']))
>>> [str(h) for h in hashes] # doctest: +NORMALIZE_WHITESPACE
['sha384-H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO',
 'sha256-qznLcsROx4GACP2dm0UCKCzCG+HiZ1guq6ZZDob/Tng=']

>>> parsed = integrity.parse(' sha256-47DEQpj8HBSa+/TImW+5JCeu'
...                          'QeRkm5NMpJWZG3hSuFU= ')
>>> parsed # doctest: +ELLIPSIS
[subresource_integrity.Hash('sha256', '47DEQp...SuFU=', '')]
>>> [str(h) for h in parsed]
['sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=']

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

subresource-integrity-0.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

subresource_integrity-0.1-py2.py3-none-any.whl (10.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file subresource-integrity-0.1.tar.gz.

File metadata

File hashes

Hashes for subresource-integrity-0.1.tar.gz
Algorithm Hash digest
SHA256 3310f7776ae636fdfb78c60f3d2058d7f725de5c252b7066125823ef3cbe911b
MD5 aba1daa0d37e5830a9e921e1c1e887ef
BLAKE2b-256 7bda9bc8bc05ccb49fbb24353e68145fd6ab0f67fb41fd60297868012bc25ce8

See more details on using hashes here.

File details

Details for the file subresource_integrity-0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for subresource_integrity-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c21458177375ce9e615f24a286e069a6f67acb64d699a609469adf3e6df0a1b7
MD5 c23bbfaf96682cea64acc004f4347802
BLAKE2b-256 676e8738000ad26fc3a13ce0b27e8bb54fbedde8c3347157f2d4f3dafdec56f9

See more details on using hashes here.

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