D
Dave
Hi,
I want to simply generate an encrypted text (with a static key) store in
a text file and validate it by decrypting the enrypted text with the
static key.
The static key is a plain text written in a C++ class.
What is the simple way of writing this sort of functions in C/C++?
I currently created two functions to deal with encryption and
decryption, but they don't functioning properly:
void Auth::encrypt(string &text)
{
const char *k = text.c_str();
const char *s = _seed.c_str();
std:stringstream encrypted_text;
char c;
for (; *k != '\0'; *k++) {
for (; *s != '\0'; *s1++) {
c = *k ^ *s;
encrypted_text << c;
}
}
text = encrypted_text;
}
string Auth::decrypt(string &line)
{
const char *l = line.c_str();
const char *s = _seed.c_str();
std:stringstream ascii_text;
char c;
for (; *l != '\0'; *l++) {
for (; *s != '\0'; *s++) {
c = *l ^ *s;
ascii_text << c;
}
}
return ascii_text.str();
}
Thanks
Sam
I want to simply generate an encrypted text (with a static key) store in
a text file and validate it by decrypting the enrypted text with the
static key.
The static key is a plain text written in a C++ class.
What is the simple way of writing this sort of functions in C/C++?
I currently created two functions to deal with encryption and
decryption, but they don't functioning properly:
void Auth::encrypt(string &text)
{
const char *k = text.c_str();
const char *s = _seed.c_str();
std:stringstream encrypted_text;
char c;
for (; *k != '\0'; *k++) {
for (; *s != '\0'; *s1++) {
c = *k ^ *s;
encrypted_text << c;
}
}
text = encrypted_text;
}
string Auth::decrypt(string &line)
{
const char *l = line.c_str();
const char *s = _seed.c_str();
std:stringstream ascii_text;
char c;
for (; *l != '\0'; *l++) {
for (; *s != '\0'; *s++) {
c = *l ^ *s;
ascii_text << c;
}
}
return ascii_text.str();
}
Thanks
Sam