PHPackages                             glanchow/wok-lfsr-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. glanchow/wok-lfsr-bundle

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

glanchow/wok-lfsr-bundle
========================

Linear Feedback Shift Register (LFSR) for Symfony2

2201PHP

Since Sep 1Pushed 12y agoCompare

[ Source](https://github.com/glanchow/WokLfsrBundle)[ Packagist](https://packagist.org/packages/glanchow/wok-lfsr-bundle)[ RSS](/packages/glanchow-wok-lfsr-bundle/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

WokLfsrBundle
=============

[](#woklfsrbundle)

Linear Feedback Shift Register (LFSR) for Symfony2

Overview
--------

[](#overview)

Installation
------------

[](#installation)

Edit composer.json

```
"require": {
...
    "glanchow/wok-lfsr-bundle": "*"
```

Then update

```
php composer.phar update
```

Configuration
-------------

[](#configuration)

```
// src app/AppKernel.php

public function registerBundles()
...
    $bundles = array(
    ...
               new Wok\LfsrBundle\WokLfsrBundle(),
```

```
# src app/config/config.yml

# Wok LSFR Configuration
wok_lfsr:
    feedback: 0xC
    state: 1
    base: null
    pad: false
```

Find your feedback term
-----------------------

[](#find-your-feedback-term)

Here's a list with taps for n up to 4096: [http://www.eej.ulst.ac.uk/~ian/modules/EEE515/files/old\_files/lfsr/lfsr\_table.pdf](http://www.eej.ulst.ac.uk/~ian/modules/EEE515/files/old_files/lfsr/lfsr_table.pdf)

Here's a list with feedback terms for n up to 40, but with multiple and differents feedback terms:

Let's say you want a maximum-length feedback term for a 8 bit LFSR.

For n = 8, possible taps are 8, 6, 5, 4.

```
$ bc
obase=16
ibase=2
10111000
B8
```

Or more simply:

```
$ bc
obase=16
2^7 + 2^5 + 2^4 + 2^3
B8
```

0xB8 is your feedback term.

### A little feedback term table

[](#a-little-feedback-term-table)

nfeedback40xC50x1E60x3670x7880xB8160xB400300x32800000310x78000000320xA3000000630x6600000000000000640xD800000000000000Usage
-----

[](#usage)

### Create an instance

[](#create-an-instance)

Using default or global configuration:

```
$lfsr = $this->get('wok_lfsr');
```

Using a custom configuration:

```
$config = array(
    'feedback' => 0xC,
    'state' => '11',
    'base' => '01',
    'pad' => true
);

$lfsr = $this->get('wok_lfsr')->config($config);
```

### Next state

[](#next-state)

```
$state = $lfsr->next();
```

Patterns
--------

[](#patterns)

### Run a complete cycle:

[](#run-a-complete-cycle)

```
$config = array(
    'feedback' => 0xC,
    'state' => 0x1,
    'base' => null,
    'pad' => false
    );
$lfsr = $this->get('wok_lfsr')->config($config);

$lfsr->setState(4);
$end = 4;
$iterations = 0;
do {
    $iterations++;
    $state = $lfsr->next();
    echo $state . "";
} while ($state != $end);
echo "$iterations iterations";
```

Cookbook
--------

[](#cookbook)

### Random looking identifier

[](#random-looking-identifier)

LFSR can be used to generate random looking identifiers for database records (mysql, postgresql, etc).

Let's say you want a short random looking identifier for one of a billion records.

```
# src app/config/config.yml

wok_lfsr:
    feedback: 0x32800000
    state: 1
    base: 0123456789bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ
    pad: true
```

Let's explain this configuration.

For a billion record we need at least 30 bits.

We've found a 30 bits feedback term over the www: 0x32800000.

The object automatically finds that this is a feedback term for a 30 bit LFSR, it's easy since a n bit LFSR needs a n tap.

To get a short word, we selected a 50 symbols base.

The object automatically finds that we need 6 symbols (50^6) to write all (2^30) words, and takes for padding symbol, the first symbol of the base.

Warning
-------

[](#warning)

### Code and processor limitation

[](#code-and-processor-limitation)

If your feedback term is greater than the server's PHP\_INT\_MAX, which is processor dependant, it will be converted to a float number and the current code will provide wrong results.

### Unsigned int

[](#unsigned-int)

PHP doesn't use the unsigned int type. In the case you want only positive numbers or use a custom base, please use at most n -1 bits of your processor capacity.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d7d19f0bd1ea354aa81f58cbe823867cbab5fd854d039bcf8873a66fd8c1a08?d=identicon)[glanchow](/maintainers/glanchow)

---

Top Contributors

[![glanchow](https://avatars.githubusercontent.com/u/1622353?v=4)](https://github.com/glanchow "glanchow (7 commits)")

### Embed Badge

![Health badge](/badges/glanchow-wok-lfsr-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/glanchow-wok-lfsr-bundle/health.svg)](https://phpackages.com/packages/glanchow-wok-lfsr-bundle)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
