Crypto: HW 7            Fall 2001            Michael Siff      

Read the handouts given in class on Thursday (10/4) before class on Monday (10/8).
The problems below are due Thursday, October 11.

    Binary numbers

  1. Write the following base-10 numbers in base-2 (show your work):
    7
    9
    62
    63
    64
    233
    244
    255

  2. Write the following base-2 numbers in base-10 (show your work):
    1001
    1101
    10010
    10101
    110100
    100101
    1111111
    11001000


    Binary arithmetic

  3. Recall, base-2 addition looks very much like base-10 addition. For example:
       1001
     + 1101
     ------
      10110
    
    Compute the following base-2 sums:
       10010          111110
     + 10101        +  10110
     -------        --------
    
    Show your work and check your results by converting the numbers to base-10 and performing addition in that more familiar system, as in:
     base 2      base 10
    ====================
       1001          9   = 8 + 1
     + 1101       + 13   = 8 + 4 + 1
     ------       ----
      10110         22   = 16 + 4 + 2
    

  4. Recall, base-2 multiplication looks very much like base-10 multiplication. For example:
       101
     x  11
     -----
       101
    + 1010
    ------
      1111
    
    Compute the following base-2 products:
       111          10001
     x 101        x   110
     -----        -------
    
    Show your work and check your results by converting the numbers to base-10 and performing multiplication in that more familiar system, as in:
     base 2      base 10
    ====================
       101          5   = 4 + 1
     x  11        x 3   = 2 + 1
     -----        ---
       101         
    + 1010
    ------     
      1111         15   = 8 + 4 + 2 + 1
    


    Algorithms Here is an algorithm for converting a number to its binary (base-2) representation:

      input d // a positive integer
      k <- 0
      while d > 0 do 
        bk <- d mod 2
        d <- d - bk
        d <- d / 2
        k <- k + 1
      output bk-1, bk-2, ... , b0
    
  5. Write an algorithm to compute (and output) the value of a binary number. Assume that the input is a binary number, k-bits long, as in:
           bk-1, bk-2, ... , b0
    
    and use the same style and form shown above.


    ASCII

    (It may be useful to consult an ASCII table.) For each of the following pieces of ASCII text, write the corresponding decimal and (8-bit) binary encodings. For example, the text is

      Cat
    
    You should write:
    symbol decimal binary
    C 67 01000011
    a 97 01100001
    t 116 01110100
  6. What?!
  7. magic8


    XOR encoding

    We can encrypt ASCII plaintext using binary keys and the XOR operation. For example, to encrypt the plaintext he using the key 00100101, we would write:

               h (symbolic plaintext)                  e (symbolic plaintext)
             104 (decimal ASCII for h)               101 (decimal ASCII for e)       
                                                                                          
        01101000 (binary ASCII for h)           01100101 (binary ASCII for e)        
    xor 00100101 (the key)                  xor 00100101 (the key)                        
        --------                                --------                                  
        01001101 (binary ciphertext)            01000000 (binary ciphertext)              
                                                                                          
              77 (decimal ciphertext)                 64 (decimal ciphertext)             
               M (symbolic ciphertext)                 @ (symbolic ciphertext)            
    
    So the ciphertext corresponding to he is M@.

  8. Encrypt the plaintext Blue with the key 00100000. Show your work as in the example above.

  9. Decrypt the ciphertext dQFFM with the key 00100011. Show your work as in the example above.


crypto home assignments labs notes tools contact instructor