密码学课程设计之线性反馈移位寄存器
#coding:utf-8 s = '10001010'#本源多项式x^8+x^4+x^3+x^2+1 a = s ls = len(s) for i in range(0,100000): s += str(int(s[i])^int(s[i+ls-4])^int(s[i+ls-3])^int(s[i+ls-2])) t1 = pow(2,ls)-1 t2 = s[ls:].find(a)+ls print "初始序列长度:%d\n理论最大周期:%d\n实际周期:%d"%(ls,t1,t2) ''' 初始序列长度:8 理论最大周期:255 实际周期:255 '''