PDA

View Full Version : suggestion for using strlen()



joseph
12th September 2008, 09:29
Hi guys,

Can i use
strlen() to find the length of binary data...?

My undetstanding is that strlen() will consider "\0" as the end of the data.
But my confusion is like , if the data is encrypted , can we trust strlen()..???


thanks in advance

lvi
12th September 2008, 10:21
You can't use strlen(), for the reason you already gave. When receiving encrypted data, you will have to have some prior knowledge on the amount of data you're (supposed to be) receiving. E.g.: uuEncoding specifies the line length in the first byte of each line, or yEncoding, that uses a terminator sequence that marks the end of the encoded data stream.

joseph
15th September 2008, 08:18
I am using "RC4 encryption " algorithm .So my questions are ,

1) Will RC4 algorithm added '\0' ( ie: null character ) at the end of encrypted data.
2) Will RC4 algorithm assure that it will not add '\0' in between encrypted data ,except at the end of the encrypted data


please help me

lvi
15th September 2008, 20:34
You can find the answer for example on Wikipedia (http://en.wikipedia.org/wiki/RC4_(cipher)). Short answers:
1) No
2) No

Longer answers:
1) Depends on the implementation of the algorithm, but generally, no.
2) Depends on the input and implementation of the encrypting algorithm.

DISCLAIMER: I infer these answers from a quick scan of the Wikipedia page, so correct me if I'm wrong...