题目描述:
Check out our brand-new cipher. It’s super-fast and moderately secure.
#!/usr/bin/python
import struct
import os
M = 65521
class LCG():
def __init__(self, s):
self.m = M
(self.a, self.b, self.state) = struct.unpack('<3H', s[:6])
def round(self):
self.state = (self.a*self.state + self.b) % self.m
return self.state
def generate_gamma(self, length):
n = (length + 1) / 2
gamma = ''
for i in xrange(n):
gamma += struct.pack('<H', self.round())