__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
from Cryptodome.Util._raw_api import (VoidPointer, SmartPointer,
create_string_buffer,
get_raw_buffer, c_size_t,
c_uint8_ptr, c_ubyte)
from Cryptodome.Util.number import long_to_bytes
from Cryptodome.Util.py3compat import bchr
from .keccak import _raw_keccak_lib
class TurboSHAKE(object):
"""A TurboSHAKE hash object.
Do not instantiate directly.
Use the :func:`new` function.
"""
def __init__(self, capacity, domain_separation, data):
state = VoidPointer()
result = _raw_keccak_lib.keccak_init(state.address_of(),
c_size_t(capacity),
c_ubyte(12)) # Reduced number of rounds
if result:
raise ValueError("Error %d while instantiating TurboSHAKE"
% result)
self._state = SmartPointer(state.get(), _raw_keccak_lib.keccak_destroy)
self._is_squeezing = False
self._capacity = capacity
self._domain = domain_separation
if data:
self.update(data)
def update(self, data):
"""Continue hashing of a message by consuming the next chunk of data.
Args:
data (byte string/byte array/memoryview): The next chunk of the message being hashed.
"""
if self._is_squeezing:
raise TypeError("You cannot call 'update' after the first 'read'")
result = _raw_keccak_lib.keccak_absorb(self._state.get(),
c_uint8_ptr(data),
c_size_t(len(data)))
if result:
raise ValueError("Error %d while updating TurboSHAKE state"
% result)
return self
def read(self, length):
"""
Compute the next piece of XOF output.
.. note::
You cannot use :meth:`update` anymore after the first call to
:meth:`read`.
Args:
length (integer): the amount of bytes this method must return
:return: the next piece of XOF output (of the given length)
:rtype: byte string
"""
self._is_squeezing = True
bfr = create_string_buffer(length)
result = _raw_keccak_lib.keccak_squeeze(self._state.get(),
bfr,
c_size_t(length),
c_ubyte(self._domain))
if result:
raise ValueError("Error %d while extracting from TurboSHAKE"
% result)
return get_raw_buffer(bfr)
def new(self, data=None):
return type(self)(self._capacity, self._domain, data)
def _reset(self):
result = _raw_keccak_lib.keccak_reset(self._state.get())
if result:
raise ValueError("Error %d while resetting TurboSHAKE state"
% result)
self._is_squeezing = False
def new(**kwargs):
"""Create a new TurboSHAKE128 object.
Args:
domain (integer):
Optional - A domain separation byte, between 0x01 and 0x7F.
The default value is 0x1F.
data (bytes/bytearray/memoryview):
Optional - The very first chunk of the message to hash.
It is equivalent to an early call to :meth:`update`.
:Return: A :class:`TurboSHAKE` object
"""
domain_separation = kwargs.get('domain', 0x1F)
if not (0x01 <= domain_separation <= 0x7F):
raise ValueError("Incorrect domain separation value (%d)" %
domain_separation)
data = kwargs.get('data')
return TurboSHAKE(32, domain_separation, data=data)
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| BLAKE2b.py | File | 9.22 KB | 0644 |
|
| BLAKE2b.pyi | File | 906 B | 0644 |
|
| BLAKE2s.py | File | 9.22 KB | 0644 |
|
| BLAKE2s.pyi | File | 739 B | 0644 |
|
| CMAC.py | File | 10.29 KB | 0644 |
|
| CMAC.pyi | File | 822 B | 0644 |
|
| HMAC.py | File | 7.98 KB | 0644 |
|
| HMAC.pyi | File | 624 B | 0644 |
|
| KMAC128.py | File | 5.82 KB | 0644 |
|
| KMAC128.pyi | File | 903 B | 0644 |
|
| KMAC256.py | File | 2.84 KB | 0644 |
|
| KMAC256.pyi | File | 226 B | 0644 |
|
| KangarooTwelve.py | File | 7.01 KB | 0644 |
|
| KangarooTwelve.pyi | File | 572 B | 0644 |
|
| MD2.py | File | 5.98 KB | 0644 |
|
| MD2.pyi | File | 492 B | 0644 |
|
| MD4.py | File | 6.44 KB | 0644 |
|
| MD4.pyi | File | 532 B | 0644 |
|
| MD5.py | File | 6.47 KB | 0644 |
|
| MD5.pyi | File | 492 B | 0644 |
|
| Poly1305.py | File | 7.92 KB | 0644 |
|
| Poly1305.pyi | File | 665 B | 0644 |
|
| RIPEMD.py | File | 1.18 KB | 0644 |
|
| RIPEMD.pyi | File | 98 B | 0644 |
|
| RIPEMD160.py | File | 6.26 KB | 0644 |
|
| RIPEMD160.pyi | File | 516 B | 0644 |
|
| SHA.py | File | 1.13 KB | 0644 |
|
| SHA.pyi | File | 169 B | 0644 |
|
| SHA1.py | File | 6.54 KB | 0644 |
|
| SHA1.pyi | File | 536 B | 0644 |
|
| SHA224.py | File | 6.75 KB | 0644 |
|
| SHA224.pyi | File | 544 B | 0644 |
|
| SHA256.py | File | 6.75 KB | 0644 |
|
| SHA256.pyi | File | 612 B | 0644 |
|
| SHA384.py | File | 6.75 KB | 0644 |
|
| SHA384.pyi | File | 544 B | 0644 |
|
| SHA3_224.py | File | 6.05 KB | 0644 |
|
| SHA3_224.pyi | File | 605 B | 0644 |
|
| SHA3_256.py | File | 6.05 KB | 0644 |
|
| SHA3_256.pyi | File | 605 B | 0644 |
|
| SHA3_384.py | File | 6.14 KB | 0644 |
|
| SHA3_384.pyi | File | 605 B | 0644 |
|
| SHA3_512.py | File | 6 KB | 0644 |
|
| SHA3_512.pyi | File | 605 B | 0644 |
|
| SHA512.py | File | 7.55 KB | 0644 |
|
| SHA512.pyi | File | 622 B | 0644 |
|
| SHAKE128.py | File | 4.66 KB | 0644 |
|
| SHAKE128.pyi | File | 437 B | 0644 |
|
| SHAKE256.py | File | 4.66 KB | 0644 |
|
| SHAKE256.pyi | File | 437 B | 0644 |
|
| TupleHash128.py | File | 4.64 KB | 0644 |
|
| TupleHash128.pyi | File | 666 B | 0644 |
|
| TupleHash256.py | File | 2.77 KB | 0644 |
|
| TupleHash256.pyi | File | 144 B | 0644 |
|
| TurboSHAKE128.py | File | 3.76 KB | 0644 |
|
| TurboSHAKE128.pyi | File | 574 B | 0644 |
|
| TurboSHAKE256.py | File | 757 B | 0644 |
|
| TurboSHAKE256.pyi | File | 306 B | 0644 |
|
| _BLAKE2b.abi3.so | File | 66.02 KB | 0644 |
|
| _BLAKE2s.abi3.so | File | 66.02 KB | 0644 |
|
| _MD2.abi3.so | File | 66.02 KB | 0644 |
|
| _MD4.abi3.so | File | 66.02 KB | 0644 |
|
| _MD5.abi3.so | File | 66.02 KB | 0644 |
|
| _RIPEMD160.abi3.so | File | 66.02 KB | 0644 |
|
| _SHA1.abi3.so | File | 66.02 KB | 0644 |
|
| _SHA224.abi3.so | File | 66.02 KB | 0644 |
|
| _SHA256.abi3.so | File | 66.02 KB | 0644 |
|
| _SHA384.abi3.so | File | 66.02 KB | 0644 |
|
| _SHA512.abi3.so | File | 66.02 KB | 0644 |
|
| __init__.py | File | 2.87 KB | 0644 |
|
| __init__.pyi | File | 2.02 KB | 0644 |
|
| _ghash_portable.abi3.so | File | 65.95 KB | 0644 |
|
| _keccak.abi3.so | File | 66.02 KB | 0644 |
|
| _poly1305.abi3.so | File | 66.02 KB | 0644 |
|
| cSHAKE128.py | File | 6.23 KB | 0644 |
|
| cSHAKE128.pyi | File | 499 B | 0644 |
|
| cSHAKE256.py | File | 2.16 KB | 0644 |
|
| cSHAKE256.pyi | File | 235 B | 0644 |
|
| keccak.py | File | 7.38 KB | 0644 |
|
| keccak.pyi | File | 741 B | 0644 |
|