Skip to content

Allow to construct a 128-bit key from two 64-bit halves#1

Open
dkruchinin wants to merge 1 commit intomajek:masterfrom
dkruchinin:key-parts
Open

Allow to construct a 128-bit key from two 64-bit halves#1
dkruchinin wants to merge 1 commit intomajek:masterfrom
dkruchinin:key-parts

Conversation

@dkruchinin
Copy link
Copy Markdown

First of all thank you for the library, it saved me some time 👍🏼

What I found slightly inconvenient is that some other libraries implementing SipHash in other languages (guava hashing, go-siphasm, etc) construct 128-bit key from two 64-bit halves, so when you want to comply the code that uses them you're forced to do something like:

import struct
import siphash
...
hash = siphash.SipHash_2_4(struct.pack('<QQ', k0, k1)).hash()
...

Which is a bit annoying because you kind of have to learn the implementation details you don't want to know (encoding endian and format). I thought something like the following might be useful:

import siphash
...
hash = siphash.SipHash_2_4.fromkeyparts(k0, k1).hash()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant