The following code is an unfinished code, as I am still not fully familiar with how to use classes in C++, I need some guiding on how to initialize this large number of integers in shown int beginning of the class definition, many people here at stackoverflow advised me not to use the constructor for all of those variables. What can I use and how? And why I shouldn't initialize many variables with the constructor?
What I am trying to achieve eventually is to compute to integers whom are the c in the RSA algorithm and I want to do it for three Users. So that the program generates 2 keys for each.
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <boost/dynamic_bitset.hpp>
using namespace std;
class LFSR:
{
int y = 0;
int turnCount = 0;
int count1 = 0, count0 = 0;
int xx = 0;
int polyLoc;
int p = 0;
int q = 0;
int d = 0;
int n = 0;
int end = 0;
int f = 0;
int e = 0;
int m = 0;
int c = 0;
int l = 0, g = 0;
boost::dynamic_bitset<> inpSeq(5);
boost::dynamic_bitset<> operSeq(5);
boost::dynamic_bitset<> bit(5);
vector <int> xorArray;
vector <int> keyReg;
public:
LFSR ();
int key ()
{
while(polyLoc>0)
{
xorArray.push_back(polyLoc%10);
polyLoc/=10;
}
sort(xorArray.rbegin(), xorArray.rend());
operSeq = inpSeq;
keyReg.push_back(inpSeq[0]);
int x = xorArray[0];
do {
for (unsigned int r = 1; r < xorArray.size(); r++)
{
bit[seq_end] = operSeq[x];
y = xorArray[r];
bit[seq_end] = bit[seq_end] ^ operSeq[y];
}
operSeq >>= 1;
operSeq[seq_end] = bit[seq_end];
keyReg.push_back(operSeq[0]);
turnCount ++;
}
while ((operSeq != inpSeq) && (turnCount < 1024));
for ( unsigned int i = 0; i < keyReg.size(); i++)
{
if (keyReg[i]==1)
{
m = m + int(pow(2,i));
}
}
n = p*q;
f = (p-1)*(q-1);
for (int k = 0; end < 1; k++)
{
if ( (1+k*f)%d == 0)
{
end = 2;
e = (1+(k*f))/d;
}
}
g = int(pow(m,e));
c = g%n;
return c;
}
};
LFSR::LFRS()
{
}
int main ()
{
}