Skip to main content
pysiphash
====

A Python implementation of [SipHash](https://131002.net/siphash/), a
fast short-input PRF.

Extract from the description:

```
SipHash is a family of pseudorandom functions (a.k.a. keyed hash
functions) optimized for speed on short messages.

Target applications include network traffic authentication and defense
against hash-flooding DoS attacks.

SipHash is secure, fast, and simple (for real):
* SipHash is simpler and faster than previous cryptographic algorithms
(e.g. MACs based on universal hashing)
* SipHash is competitive in performance with insecure
non-cryptographic algorithms (e.g. MurmurHash)
* We propose that hash tables switch to SipHash as a hash
function. Users of SipHash already include OpenDNS, Perl 5, Ruby, or
Rust.
```

usage
----

`Pysiphash` tries to follow the
[hashlib](http://docs.python.org/2/library/hashlib.html) API. You can
add data to the hash by calling an `update` method, or feed data
directly to the constructor:

```:python
>>> import siphash
>>> key = '0123456789ABCDEF'
>>> sip = siphash.SipHash_2_4(key)
>>> sip.update('a')
>>> sip.hash()
12398370950267227270L

>>> siphash.SipHash_2_4(key, 'a').hash()
12398370950267227270L
```

To extract the hash as a numeric value call `hash()`:

```
>>> siphash.SipHash_2_4(key, 'a').hash()
12398370950267227270L
```

Or `digest()` to get a raw 8-bytes string:
```:python
>>> siphash.SipHash_2_4(key, 'a').digest()
'\x86L3\x9c\xb0\xdc\x0f\xac'
```

Or `hexdigest()` for a 16-bytes hex encoding:
```:python
>>> siphash.SipHash_2_4(key, 'a').hexdigest()
'864c339cb0dc0fac'
```

testing
----

A series of sanity checks are present inline the main `pysiphash`
code, to run it type:

```:bash
$ python siphash/__init__.py
all tests ok
```

speed
----

Currently `pysiphash` is a pure-python code, so don't expect blazing
speed. On my machine computing a hash from a ten byte string takes
around 0.31 ms, and hashing 1MiB blob takes 770 ms.

Metadata

Release files for siphash 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for siphash 0.0.1
File Size Uploaded Provenance
siphash-0.0.1.tar.gz 5.9 kB Without provenance Details

Release files / siphash-0.0.1.tar.gz

Download URL siphash-0.0.1.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
aee97fe95e09a2995819c058a5e4ac6d96661a898d7fe0ad55e3b72c9a31d461
BLAKE2b-256 checksum
How to use checksums
8aff203e8bf26c5658f4df97a966c32f21dd9125d740e7c92795ca1055b45772
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for siphash 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page