The code works ok for small lenght chars, but i have passed a char variable with 1756 positions, and only the first 272 are crypted, all the remaining text disappears, i can't figure out why. Any ideas ?
As said in the other thread, "strlen" will count the characters until a null-character is found. When you XOR a value with it self, it will become zero/null, so "strlen" is only valid for plain text.
Hi Danois,
but it's still something i am not understading, let me explain what i have done:
1 => First i call this function passing plain text. This char has 1756 positions in plain text.
2 => the function passes through all positions, but the output only shows around 125 chars.
When i make the int insize = strlen(input), this gives the correct lenght of the char, so that's why i am not understading.
This is an example what i am trying to encrypt, it's random text for test purposes:
Danois90:
As said in the other thread, "strlen" will count the characters until a null-character is found. When you XOR a value with it self, it will become zero/null, so "strlen" is only valid for plain text.
The function in #1 is only valid for encryption, if you use "strlen" on an encrypted buffer, it will only count characters until the for null-char is found and not the entire buffer. You need to store the length of the plaintext message and use the stored value for decryption instead of "strlen".
Yes, i understood, but my problem is that on function #1, when encrypted plain text, only first 126 characters of that example are crypted and i dont understand why
Danois90:
The function in #1 is only valid for encryption, if you use "strlen" on an encrypted buffer, it will only count characters until the for null-char is found and not the entire buffer. You need to store the length of the plaintext message and use the stored value for decryption instead of "strlen".
whoops... my bad man, i had a bug in code, however, i was not taking in consideration to store the lenght after crypt the values, it's now all working fine, many, many thanks! i've been struggling with this for a week now
Thanks!!!
Danois90:
How do you know that only the first 126 characters are being encrypted?