项目作者: kpdemetriou

项目描述 :
Tested, performant SipHash bindings for Python 3 with support for double-output-size, half-word and variable-round variants.
高级语言: C
项目地址: git://github.com/kpdemetriou/siphash-cffi.git
创建时间: 2018-06-19T18:39:47Z
项目社区:https://github.com/kpdemetriou/siphash-cffi

开源协议:BSD 3-Clause "New" or "Revised" License

下载


SipHash CFFI

SipHash is a family of pseudorandom functions (i.e. keyed hash functions) optimized for speed on short messages, designed by Jean-Philippe Aumasson and Daniel J. Bernstein.

This package provides tested, performant Python 3 CFFI bindings to the SipHash 2-4 reference implementation by Jean-Philippe Aumasson (including support for double-output-size and half-word variants) along with extensions to support tweakable numbers of compression and finalization rounds.

Installation

You can install this package using pip or the included setup.py script:

  1. # Using pip
  2. pip install siphash-cffi
  3. # Using setup.py
  4. python setup.py install

Usage

  1. from siphash import *
  2. # Demonstration key and data
  3. key = b"\0" * 16
  4. data = b"\0" * 64
  5. # SipHash-2-4 working with 64-bit words and a 64-bit output length
  6. output = siphash_64(key, data)
  7. # SipHash-2-4 working with 64-bit words and a 128-bit output length
  8. output = siphash_128(key, data)
  9. # SipHash-2-4 working with 32-bit words and a 32-bit output length
  10. output = half_siphash_32(key, data)
  11. # SipHash-2-4 working with 32-bit words and a 64-bit output length
  12. output = half_siphash_64(key, data)
  13. # SipHash-4-8 working with 64-bit words and a 64-bit output length
  14. output = siphash_64(key, data, 4, 8)
  15. # SipHash-4-8 working with 64-bit words and a 128-bit output length
  16. output = siphash_128(key, data, 4, 8)
  17. # SipHash-4-8 working with 32-bit words and a 32-bit output length
  18. output = half_siphash_32(key, data, 4, 8)
  19. # SipHash-4-8 working with 32-bit words and a 64-bit output length
  20. output = half_siphash_64(key, data, 4, 8)

License

  1. BSD 3-Clause License
  2. Copyright (c) 2018, Phil Demetriou
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright notice, this
  7. list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright notice,
  9. this list of conditions and the following disclaimer in the documentation
  10. and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the names of its
  12. contributors may be used to endorse or promote products derived from
  13. this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  15. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  18. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  20. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  21. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  22. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.