Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <bitset>
- using namespace std;
- int LFSR (void)
- {
- static unsigned long SHH = 0xFFFFFFFF;
- static unsigned long SHL = 0xFFFFFFFF;
- static unsigned long SLH = 0xFFFFFFFF;
- static unsigned long SLL = 0xFFFFFFFF;
- char counter = 32;
- unsigned int value = 0;
- do {
- int S = (( (SLL>>2)^(SLL>>27)^(SLL>>29)^SLL ) & 1);
- SLL = (SLL>>1) | ((SLH & 1)<<31);
- SLH = (SLH>>1) | ((SHL & 1)<<31);
- SHL = (SHL>>1) | ((SHH & 1)<<31);
- SHH = (SHH>>1) | (S<<31);
- counter--;
- value = (value<<1) | (SLL & 1);
- } while (counter > 0);
- return value;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- for (int i=0; i<0xFFFF; i++) {
- std::cout << std::bitset<32>(LFSR());
- }
- std::getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment