Gelembjuk wrote:
> Hello.
> I have data encoded with base64. I need to decode it but i must to do
> it part by part.
> I read bytes from stream. I must read some part (8000 bytes or any
> other count that is not too big, less then 10000) then i need to
> decode this part of data and write to another stream.
>
> I found that if i just read part of data and decode it with
> base64_decode then final decoded data are not correct.
> If there a way to decode base64 encoded data part by part?
Interesting problem you have, I can understand why you want to decode
only sections of a base64 encoded stream and not the entire lot .
base64 encoded string "hello world" gets turned into aGVsbG8gd29ybGQ=
now its been a long time since ive done bitwise encoding ( back in
asm/pascal graphic programming days for dos ) so i had to look up how
base64 encoding works
found a nice article on how it works
http://email.about.com/cs/standards/a/base64_encoding.htmits mostly about email but its a good start
if you miss grab the wrong parts you can get erroneous results.
Now assuming if its practical and you know the exact structure of the
stream you could use functions like chunk_split ,unpack or even preg
functions to get the correct data.
personally i would do a base64_decode and work on the resulted string
thereafter.
Without knowing exactly what your source or your code is thats the best
I can offer
regards trookat