0

Hi,

I am using RC4 to encrypt the data. It works fine. But I found that some encrypted values contains NULL character or other escape characters in result. Due to which when I read the string back to decrypt, does not give the whole string back but truncate the string.

Can any one help how can I verify if the whole string has any such characters or when decrypting I can avoid them?

Thanks in advance!!

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by mLearning
0

I read the string back to decrypt, does not give the whole string back but truncate the string.

Then you are opening the file incrrectly. Since the file contains embedded NULL bytes it must be opened in binary mode and use std::string's read() method.

when decrypting I can avoid them?

You can't just ignore them because they are part of the encryption algorithm. Decryption will be rendered useless without them.

0

Then you are opening the file incrrectly. Since the file contains embedded NULL bytes it must be opened in binary mode and use std::string's read() method.

I actually solved this portion:
I was reading file one line at a time. . . And I was looking for new line character so I can find the end of line. But I figure out that with new line character I also have to look for "Carriage Return". This also solves my other question as I am now looking for pattern "\r\n" which will be at the end only and which will not truncate the string at any point.

Thank you for help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.