�
���g � � � d Z ddlmZ ddlmZ deeeef defd�Z G d� de � � Z
G d � d
e � � Z G d� d� � Zd
S )a
Hashing function for dataset keys using `hashlib.md5`
Requirements for the hash function:
- Provides a uniformly distributed hash from random space
- Adequately fast speed
- Working with multiple input types (in this case, `str`, `int` or `bytes`)
- Should be platform independent (generates same hash on different OS and systems)
The hashing function provides a unique 128-bit integer hash of the key provided.
The split name is being used here as the hash salt to avoid having same hashes
in different splits due to same keys
� )�Union)�insecure_hashlib� hash_data�returnc � � t | t � � r| S t | t � � r| � dd� � } n4t | t � � rt | � � } nt | � � �| � d� � S )z|
Returns the input hash_data in its bytes form
Args:
hash_data: the hash salt/key to be converted to bytes
�\�/zutf-8)�
isinstance�bytes�str�replace�int�InvalidKeyError�encode)r s �`/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/datasets/keyhash.py� _as_bytesr &