The idea is to generate non cryptographic numbers using a Linear Congruential Generator. It has an internal state consisting of a number xi initially set to x0 = seed. I need to take out the output bytes of given length from this generator.
print("The formula is: X(k+1) = a * Xk + c mod m")
seed_num = int(input("Enter seed number: "))
multiplier = int(input("Enter the multiplier(a): "))
increment = int(input("Enter the increment(c): "))
modulus = int(input("Enter the modulus (m): "))
unit = int(input("How many random numbers would you like to generate?\nInput: "))
def lcg():
num_base = seed_num
for i in range(unit, 0, -1):
rd = (multiplier * num_base + increment) % modulus
print(rd)
num_base = rd
lcg()
I need to get a byte array from what is being generated using this LCG code. I need the output bytes sequentially starting from the byte generated in the first iteration and ending with the byte generated in the last iteration.