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!!

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.