Name: Anonymous 2012-11-08 0:13
So I'm trying to build a shitty text encryption proggy, however, I'm stuck @ the part where I'm supposed to revert it back to normal.
So what's the problem in this code?
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
char userluv[800], orig[800], key [51], priv [21];
int tempfussd[800], kint, pint, tint[5], c;
//get the basic info
cout << "key? ";
gets(key);
cout << "Second key? ";
gets(priv);
cout << "Your lovely text?:";
cin.get();
gets(userluv);
for(c=0; c<=key[c]; c++){
kint += key[c];
}
for(c=0; c<=priv[c]; c++){
pint += priv[c];
}
//do shit to your key
tint[0] = strlen(key) + strlen(priv);
tint[1] = tint[0] * tint[0];
//string to int then do shit :S
for(c=0; c<=userluv[c]; c++){
tempfussd[c] = userluv[c];
tempfussd[c] += kint;
tempfussd[c] *= pint;
tempfussd[c] *= tint[1];
cout << tempfussd[c];
}
cout << "\n";
//testing purposes
for(c=0; c<=userluv[c]; c++){
orig[c] = tempfussd[c];
orig[c] %= tint[1];
orig[c] %= pint;
orig[c] -= kint;
cout << orig[c];
}
return 0;
}
So what's the problem in this code?
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
char userluv[800], orig[800], key [51], priv [21];
int tempfussd[800], kint, pint, tint[5], c;
//get the basic info
cout << "key? ";
gets(key);
cout << "Second key? ";
gets(priv);
cout << "Your lovely text?:";
cin.get();
gets(userluv);
for(c=0; c<=key[c]; c++){
kint += key[c];
}
for(c=0; c<=priv[c]; c++){
pint += priv[c];
}
//do shit to your key
tint[0] = strlen(key) + strlen(priv);
tint[1] = tint[0] * tint[0];
//string to int then do shit :S
for(c=0; c<=userluv[c]; c++){
tempfussd[c] = userluv[c];
tempfussd[c] += kint;
tempfussd[c] *= pint;
tempfussd[c] *= tint[1];
cout << tempfussd[c];
}
cout << "\n";
//testing purposes
for(c=0; c<=userluv[c]; c++){
orig[c] = tempfussd[c];
orig[c] %= tint[1];
orig[c] %= pint;
orig[c] -= kint;
cout << orig[c];
}
return 0;
}