{"id":21452660,"url":"https://github.com/nmrr/lfsr","last_synced_at":"2025-04-22T10:45:37.606Z","repository":{"id":152609330,"uuid":"106173140","full_name":"nmrr/LFSR","owner":"nmrr","description":"An efficient linear feedback shift register (LFSR) class written in C++","archived":false,"fork":false,"pushed_at":"2022-12-23T19:07:11.000Z","size":20,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-23T04:33:44.057Z","etag":null,"topics":["lfsr"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nmrr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-08T12:04:26.000Z","updated_at":"2024-07-23T09:32:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"886c21d7-b55e-4b0e-ae24-aaf78720bd97","html_url":"https://github.com/nmrr/LFSR","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmrr%2FLFSR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmrr%2FLFSR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmrr%2FLFSR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmrr%2FLFSR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nmrr","download_url":"https://codeload.github.com/nmrr/LFSR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235284186,"owners_count":18965105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lfsr"],"created_at":"2024-11-23T04:31:14.201Z","updated_at":"2025-01-23T12:28:57.397Z","avatar_url":"https://github.com/nmrr.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LFSR\nAn efficient linear feedback shift register (LFSR) class written in C++\n\n# How to use this library ?\n\nCopy **LFSR.c** and **LFSR.h** to your project and import the library :\n```cpp\n#include \"LFSR.h\"\n```\n\nTo create an LFSR : (by default all bits are set to 0. Here a 15 bits LFSR is created)\n```cpp\nLFSR lfsr(15);\n```\n\nTo initialize the LFSR, the first bit is set to 1\n```cpp\nlfsr.setBit(0, true);\n```\n\nTo perform a right shift with X0 xor X1 as feedback (X15 + X14 + 1 in polynomial notation)\n```cpp\nlfsr.rightShift(lfsr.getFirstBit() xor lfsr.getBit(1) xor lfsr.getBit(4));\n```\n\nDisplay first 8-bit of the LFSR :\n```cpp\nlfsr.get8bit()\n```\n\n# All functionalities explained :\n\nGet the size in bit of the register :\n```cpp\nuint32_t getSize();\n```\n\nGet the raw value of the \n```cpp\nuint32_t getArrayElement(uint32_t bitPosition);\n```\n\nGet the size of internal 32-bit array used for the register\n```cpp\nuint32_t getArraySize();\n```\n\nPerform a right shift\n```cpp\nvoid rightShift(bool last);\n```\n\nPerform a left shift\n```cpp\nvoid leftShift(bool first);\n```\n\nGet first 8-bit \n```cpp\nuint8_t get8bit();\n```\n\nGet first 16-bit\n```cpp\nuint16_t get16bit();\n```\n\nGet first 32-bit\n```cpp\nuint32_t get32bit();\n```\n\nGet the value at a specific position in the internal 32-bit array used for the register\n```cpp\nuint32_t get32bitArray(uint32_t position);\n```\n\nGet a specific bit :\n```cpp\nbool getBit(uint32_t bitPosition);\n```\n\nGet the first bit (equivalent to getBit(0) :\n```cpp\nbool getFirstBit();\n```\n\nGet the last bit :\n```cpp\nbool getLastBit();\n```\n\nSet a specific bit\n```cpp\nvoid setBit(uint32_t bitPosition, bool value);\n```\n\nSet the first bit (equivalent to setBit(0, value))\n```cpp\nvoid setFirstBit(bool value);\n```\n\nSet the last bit\n```cpp\nvoid setLastBit(bool value);\n```\n\nSave the content of the register to a buffer\n```cpp\nvoid save(uint32_t * \u0026output);\n```\n\nCompare the register to a saved register\n```cpp\nbool compare(uint32_t * \u0026output);\n```\n\nRestaure the register with a saved register \n```cpp\nvoid set(uint32_t * \u0026output);\n```\n\n## Examples \n\nThe example calculates the length cycle of a 15 bits register with X15 + X14 + 1 as feedback\n\nTo build the sample : \n```\ng++ -std=c++11 LFSR.cpp main.cpp -o lfsr\n```\n\nOutput of the sample is : \n```\ncounter = 32767\n```\n\n**Samples** folder contains some use cases like **A5/1 encryption** \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmrr%2Flfsr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnmrr%2Flfsr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmrr%2Flfsr/lists"}