N
Nemok
Hi,
I am trying to write an additive encryption algorithm in C++ that will
encrypt a text by adding a random numer to each character in a string.
The code looks similar to this:
for(int i=0;i<=tlength-1;i++)///tlength is the length of the string to
encrypt
{
ctext+=x+i;/////x is a random number and ctext is a char*
ctext+=cpass[i%plength]+tlength;///////cpass is the key
(password)
ctext[tlength-1-i]+=x-i;
}
The problem is that while adding to the values of each char that char
might be 0 which will be interpreted like the ending NULL character of
the string. So what I need is a reversable method of
elliminating\replacing all 0 values with other values and then on
decryption of the encrypted string restore them. I can't just replace
the 0 values with another value because that value might also be
encountered in another char on decryption and will be wrongfully
transformed to 0. Please help.
Thanks.
I am trying to write an additive encryption algorithm in C++ that will
encrypt a text by adding a random numer to each character in a string.
The code looks similar to this:
for(int i=0;i<=tlength-1;i++)///tlength is the length of the string to
encrypt
{
ctext+=x+i;/////x is a random number and ctext is a char*
ctext+=cpass[i%plength]+tlength;///////cpass is the key
(password)
ctext[tlength-1-i]+=x-i;
}
The problem is that while adding to the values of each char that char
might be 0 which will be interpreted like the ending NULL character of
the string. So what I need is a reversable method of
elliminating\replacing all 0 values with other values and then on
decryption of the encrypted string restore them. I can't just replace
the 0 values with another value because that value might also be
encountered in another char on decryption and will be wrongfully
transformed to 0. Please help.
Thanks.