MCPcopy Create free account
hub / github.com/BIT-DataLab/LakeBench / sha1_hash32

Function sha1_hash32

join/LSH/datasketch/minhash.py:8–17  ·  view source on GitHub ↗

A 32-bit hash function based on SHA1. Args: data (bytes): the data to generate 32-bit integer hash from. Returns: int: an integer hash value that can be encoded using 32 bits.

(data)

Source from the content-addressed store, hash-verified

6import struct
7
8def sha1_hash32(data):
9 """A 32-bit hash function based on SHA1.
10
11 Args:
12 data (bytes): the data to generate 32-bit integer hash from.
13
14 Returns:
15 int: an integer hash value that can be encoded using 32 bits.
16 """
17 return struct.unpack('<I', hashlib.sha1(data).digest()[:4])[0]
18
19
20# The size of a hash value in number of bytes

Callers

nothing calls this directly

Calls 1

digestMethod · 0.80

Tested by

no test coverage detected