Linear Feedback Shift Register: PyLFSR¶
Github Page | Discussion Forum | Github
![]() |
Linear Feedback Shift Register - Documentation.
PyLFSR is an open source Python library to create Pseudo-Random Generator based on Linear Feedback Shift Registe. It is easy to use and create Pseudo-Random Generator, with custom configurations, such as A5/1, its enhacement, Geffe Genrator and many more. A generated sequence can be tested across different properties.
A simple example of generating 5-bit LFSR with feedback polynomial of p(x) = x5+ x4+ x3+ x2+1 :
import numpy as np
from pylfsr import LFSR
state = [0,0,0,1,0]
fpoly = [5,4,3,2]
L = LFSR(fpoly=fpoly,initstate =state)
# Generate K-bits
k=10
seq_k = L.runKCycle(k)
print('10 bits')
print(seq_k)
# Generate bits of one full period.
# Expected period of LFSR = 2^M-1, for M-bit LFSR).
seq_full = L.runFullPeriod()
#
print('Full period of LFSR = 31-cycles')
print(seq_full)
10 bits
[0 1 0 0 0 1 1 1 0 1]
Full period of LFSR = 31-cycles
[0 1 0 0 0 1 1 1 0 1 1 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 1]
Authors/Contacts:
Authors: Nikesh Bajaj, Jesús Requena Carrión
Version: 1.0.7 | 03/01/2023
Homepage : https://pylfsr.github.io
Feedback/Contact/Contribute
If any doubt, confusion or feedback please contact me
n.bajaj[AT]qmul.ac.uk
n.bajaj[AT]imperial.ac.uk
nikkeshbajaj[AT]gmail[dot?]
Nikesh Bajaj: http://nikeshbajaj.in
Queen Mary University of London
Imperial Collage London
Github Page | Discussion Forum | Github