Mask generation function: Difference between revisions

Content deleted Content added
m Example code: note it's python2 code (ie not python3)
Example code: update to python 3.10
Line 66:
 
def i2osp(integer: int, size: int = 4) -> str:
return b"".join([chr((integer >> (8 * i)) & 0xFF).encode() for i in reversed(range(size))])
 
def mgf1(input_str: strbytes, length: int, hashhash_func=hashlib.sha1) -> str:
"""Mask generation function."""
counter = 0
output = b""
while len(output) < length:
C = i2osp(counter, 4)
output += hashhash_func(input_str + C).digest()
counter += 1
return output[:length]