18 from cryptography.hazmat.primitives
import hashes
23 def __init__(self, data: bytes) ->
None:
27 def update(self, data: bytes) ->
None:
29 Sets the internal state of the buffer
30 to the provided bytes array
35 new internal state of the buffer
43 Retrieves the byte at the current position, and
44 increments internal state
48 int -> byte at the current position
52 OverflowError -> if the bytes have been exhausted
55 if self.position >= len(self.data):
58 byte = self.data[self.position]
67 Random generator based on recursive hashing the provided seed
68 using the provided hashing algorithm. Entropy is equal to the
72 def __init__(self, seed: bytes, algorithm: hashes.HashAlgorithm) ->
None:
75 numberGenerator = hashes.Hash(algorithm)
76 numberGenerator.update(seed)
85 int -> randomly generated byte value
89 return self.
_buffer_buffer.get()
93 numberGenerator = hashes.Hash(self.
algorithmalgorithm)
106 # of how many bytes should be generated
110 bytes -> randomly generated bytes array
113 values = bytearray(count)
115 for i
in range(count):
bytes getRandomBytes(self, int count)