Coder Social home page Coder Social logo

lfsr's Introduction

An implementation of a Galois LFSR, along with some helpful utilities.

What is it?

A linear feedback shift register (LFSR) is a shift register whose input is a linear function of its state.

There are two variations, the Fibonacci LFSR and the Galois LFSR.

The Fibonacci LFSR determines the input bit by the exclusive-or of the output bit and the 'tap' bits, or taps.

The Galois LFSR, bits are shifted right unchanged unless they are taps, in which case they are XORd with the output bit.

Their equivalence is better illustrated here.

Along with the implementation of a Galois LFSR, in this repository you will find:

  • A pseudo random number generator using said LFSR, in prng.c
  • A table of taps for constructing maximum length GLFSRs, in lfsr_table.txt
  • A Python implementation of a GLFSR, in lfsr.py
  • A Python implementation of the Berlekamp-Massey algorithm, for finding the minimal LFSR that generates a given sequence, in lfsr.py

How to use

You can use the Galois LFSR implementation anywhere where you would need a LFSR implementation. If performance is critical, I suggest you find more efficient, parallel implementations. Or, hire me to write one for you. Use cases for LFSRs are simple PRNGs, weak stream ciphers, white noise generators, signature analysis, signal scrambling, and test pattern generation.

The Python module can be used without any dependencies other than the standard library in all similar use cases.

How to build

lfsr.c and prng.c contain C89, C99, and C11-compatible code. Compile with:

$(CC lfsr.c prng.c)

lfsr.py is compatible with both Python 2 and Python 3, but has only been tested against Python 3.5.

lfsr's People

Contributors

mfukar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.