The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+17 votes
3.9k views

You are given the following four bytes :

 10100011  00110111  11101001  10101011

Which of the following are substrings of the base $64$ encoding of the above four bytes?

  1. $\text{zdp}$
  2. $\text{fpq}$
  3. $\text{qwA}$
  4. $\text{oze}$
asked in Computer Networks by Boss (19.1k points)
edited by | 3.9k views
+1
is it in cse syllabus 2017?
+1
Is it? any information?
+1
i think it is in syllabus ,

it is from Application Layer Protocols , MIME protocol

3 Answers

+25 votes
Best answer

Your are given the following four bytes :

$10100011\qquad 00110111\qquad 11101001\qquad 10101011 =32 +\text{ADD 4 0's}=36$
accoding to wikipedia, make pair of 6 should be made. https://en.wikipedia.org/wiki/Base64

$101000\qquad 110011\qquad 011111\qquad 101001\qquad 101010\qquad 11\mathbf{0000}$

$40$         $51$       $31$       $41$        $42$        $48$

$o$            $z$          $f$          $p$           $q$           $w$      from $\text{base-64}$ table.

Now, the longest substring will be from option checking  is 'fpq'

answered by (189 points)
edited by
+4
why append 0's on right side?doesn't it change the meaning?
+4
why zeros are put  at RHS and not at LHS ?

As we usually do while converting  binary to HEX.
+13

why it is padded at right side to left side ?

To pad it in the left side we need to know the length of the data in advance.Which is not possible to know in advance so padding is require at right side.

We know  length is 6 bit as we get from base 64 table .


But if the data is 24 bits then no problem because no padding.

If data is 32 bit then 6 + 6 + 6 + 6 + 6 + 2 
Then we have to pad 4 0's with last part .

If data is 40 bits then 6 +6+6+6+6+6+4
Then we have to pad 2 0's with last part .

So we cannot predict from the start whether 4 zero or 2 zero will be padded.

It is only in the end of the data ,i.e on the right side where we know how much to pad. This is the only reason for padding at RHS rather than LHS .

0
@Bikram sir.Then why cant we do padding on RHS for hexa decimal ?

If i have 10. then we will pad two zeros on left and not on right.Can you tell the difference between this?
0

rahul sharma 5

each hexadecimal digit represents four binary digits (bits),

In hexa decimal we know the length of the data in which size we need to convert in advance so it is padded at left side.

But here in this question we don't know in which size we neeed to convert so padded at right side.

+4
Hexa is base 16 and we pair group of 4 bits

Octal is base 8 and we pair group of 3 bits

With similar assumption If base is 64 we will pair 6 bits?
0

 rahul sharma 5 

If base is 64 we will pair 6 bits , yes , it is fine..

But if the data is 24 bits then no problem because no padding require. 

If data is 32 bit then 6 + 6 + 6 + 6 + 6 + 2  
Then we have to pad 4 0's with last part . 

If data is 40 bits then 6 +6+6+6+6+6+4 
Then we have to pad 2 0's with last part . 

So we cannot predict from the start whether 4 zero or 2 zero will be padded.

It is only in the end of the data ,i.e on the right side where we know how much to pad. This is the only reason for padding at RHS rather than LHS .

+2
but sir in the question we are already told that we need to convert it to base 64. so we know that it is to be converted  to base 64 wthen why padding on right?
0

sir i dont understand why bits are padded on rhs?

sir you said that to pad a bits in rhs we need to know the length of the data in advance.

but sir when we pad bits in rhs we also need to know data length in advance.

you said if we have 32 bits , if we know about bits we can pad after 32 bit in lhs.

please clarify sir i dont know where i am wrong.

+1

Bikram sir...when we are converting binary to hexa or  octal or other  then padding is done left side but here 

data is given in binary form and we are converting into base 64( to represent 64..we need 6 bits) then it should be also using left padding ???

0
can anyone plese tell me why right pading is done here ? not clear even after @Bikram sirs answer.
0

@Bikram Sir, do we need to remember the base 64 table?, Also if they ask problems on base 128 table, how to develop it?

+7 votes
Base64

Answer (B)

string = czfpqw

sub string =  fpq

answered by Junior (735 points)
+1
first 6 bits are 101000 which is equivalent to 40 that corresponds to 'o' then why are you writing it as c ?
0

Your are given the following four bytes :

10100011            00110111            11101001            10101011 =32 + ADD 4 0's = 36
accoding to wikipedia pair of 6 should be made. https://en.wikipedia.org/wiki/Base64

101000 110011 011111 101001 101010 110000
40         51       31       41        42        48

o           z         f         p          q          w      from base 64 table.
now the longest substring will be from option checking  is 'fpq'

0
@jayesh..kindly elaborate your solution, it is not clear to me
0
@Manish,kindly elaborate your solution
0
True ...Instead of c have a o ...may be he misstype.
0 votes
As it is asking substring of the base 64 and the given numbers are binary, so we need to make it pair of 6,

Because 2^6=64,

So the pairs will be 101000 | 110011 | 011111 | 101001 | 101010 | 11

The last number has only 2 bits so we will use padding so it'll be 110000

So they will be 40 51 31 41  42 and 48

Which is equals to o z f p q w ( see the base table of 64)

so the substring is "fpq".
answered ago by (135 points)
Answer:

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

43,962 questions
49,517 answers
162,466 comments
65,759 users