View Single Post
Old 07-04-2008   #5
MARX ®
Registered Member
 
MARX ®'s Avatar
 
Last Online: 02-15-2012
Join Date: Oct 2007
Posts: 1,301
Thanks: 1,291
Thanked 663 Times in 428 Posts
Groans: 4
Groaned at 0 Times in 0 Posts
Default Re: Encryption Pre-challenge - Base64

Quote:
In the case where a binary sequence is not an integral size of 3 bytes, then you have a representation problem. There are two cases to consider. When after regrouping each series of 3 bytes as 4 base-64 characters, you will have zero, one or two bytes left over.
The problem occurs in the cases where you have one or two bytes remaining. How do you represent these instances? Let’s consider each case separately.
The first case where you have one byte remaining, you should pad two additional bytes with all zeros onto the end of the binary sequence. You can then represent the one byte with two base-64 characters followed by two padding characters. The padding character in base-64 is ‘=’.
Let consider an example.
‘00000001’
Pad the single-byte instance with two more bytes of zeros.
‘00000001’ ‘00000000’ ‘00000000’
Now break up the binary sequence in sets of six bytes.
‘000000’ ‘010000’ ‘000000’ ‘000000’
Take the first two base-64 characters and pad two ‘=’ characters to the end of the
sequence.
‘AQ==’
The second case is where you have two bytes remain.
‘00000010’ ‘00000001’
Here you should pad one additional zero byte to the end of the binary sequence.
‘00000010’ ‘00000001’ ‘00000000’
Now break up the binary sequence in sets of six bytes.
‘000000’ ‘100000’ ‘000100’ ‘000000’
We then take three base-64 characters and pad with one ‘=’ sign.
‘AgE=’
This part i didnt get its idea
in the examples, i didnt know keef tol3o l results
MARX ® is offline   Reply With Quote