资源简介
Berlekamp-Massey Algorithm 密码学B-M算法的python语言实现
代码片段和文件信息
def Berlekamp_Massey_algorithm(sequence):
N = len(sequence)
s = sequence[:]
for k in range(N):
if s[k] == 1:
break
f = set([k + 1 0])
l = k + 1
g = set([0])
a = k
b = 0
for n in range(k + 1 N):
d = 0
for ele in f:
d ^= s[ele + n - l]
if d == 0:
b += 1
else:
if 2 * l > n:
f ^= set([a - b + ele for ele in g])
b += 1
else:
temp = f.copy()
f = set([b - a + ele for ele in f]) ^ g
l = n + 1
- 上一篇:python实现pdf转word
- 下一篇:五星红旗代码
评论
共有 条评论