题目:
构造一个跟这个一样的串
解答:
周期展开,整体异或
''' @Time : 2020/10/8 16:17 @Author : laolao @FileName: 流密码.py P17页 ''' def Page_17(): a = [1, 0, 0, 1, 1] s = [] for i in range(35): # t=a[0] # for j in range(1,5): # t=t^a[j] t = a[0] ^ a[3] print(a) s.append(a[0]) a.pop(0) a.append(t) print("输出序列:{}".format(s)) def Homework(): a = [1, 0, 1] s = [] for i in range(32): t = a[2] ^ a[0] print(a) s.append(a[0]) a.pop(0) a.append(t) print("输出序列:{}".format(s)) return s def Same_Homework(): a = [1, 0, 1, 0, 0, 1] s = [] for i in range(32): # t = a[0] ^ a[2] t=a[0] for j in range(1,len(a)): t=t^a[j] print(a) s.append(a[0]) a.pop(0) a.append(t) print("输出序列:{}".format(s)) return s if __name__ == '__main__': s1 = Homework() s2 = Same_Homework() print("*" * 50) print("目标:{}".format(s1)) print("构造:{}".format(s2))