Joseph Tarango
Department of Computer Science and Engineering
Bourns College of Engineering
University of California, Riverside

Home
CS120B | Syllabus
Lab 1 | Lab 2 | Lab 3 | Lab 4 | Lab 5 | Lab 6 | Lab 7 | Game Project

Lab 2: Deciphering Text via Bit Manipulation Techniques


In this lab you will be given a string of enciphered text and must decode the hidden message.

  • The algorithm for decrypting the text is as follows:
    • Every odd numbered character is a character of the text, every even numbered character is part of the encryption key for the previous letter. For instance, in the text "Htetltltot", the encrypted text is actually "Hello" with every key being the letter 't'
    • The first step to decoding a text character is to shift the middle four bits of the character byte to the right so that the character then becomes:
      A7A6A5A4A3A2A1A0 => A7A6A1A0A5A4A3A2
    • Finally, for every character in the text, you need to bitwise XOR the encrypted character with the associated key. So, bitwise XOR the manipulated 1st character (piece of text) with the second character (the key), and so forth.
  • Remember that XOR is an Exclusive Or operation.  The result of an XOR operation is only '1' when only a single '1' was present in the input.  The operator in C for an XOR operation is the carrot symbol ' ^ '.
  • Input each character of the enciphered message via PINA, by setting PINA equal to the associated binary value of the character.
  • Use PINB to read in the key that is associated with the character on PINA.  In the above example, PINB would always be 't', as the value of PINA changed as 'Hello' was spelled out.
  • Output the decrypted text character to PORTC.
  • Remember to set your Data Direction Registers (DDRx) for each port of the microcontroller.
  • Here is the enciphered text, given to you in ASCII values. Here is a link to an ascii chart which will give you the appropriate conversions to hexadecimal/binary values.
    • 'o#q*d8GgY<Y7t!\2eFA-M6d<L-R
    • In the above text, " ' "  is the first character of the hidden message, and "o" is the key to deciphering the first character.
  • When you think you know what the message says, call over a TA for verification.

POST LAB

INDIVIDUALLY prepare and submit a single-spaced half page report with the following information. Include the text of the deciphered message in your report.

I.     Lab Objective
II.   Personal Contributions
III. Skill learned & knowledge gained.

Turnin

INDIVIDUALLY prepare and submit all lab files into a tar ball. All .c files should be included in lab parts, as well as post lab submitted in pdf and txt format. All files should include a header with name, login, email, lab section, assignment, and group associates; also include: "I acknowledge all content is original."

For Example
Name: John Doe
Login: jdoe
Email: jdoe@cs.ucr.edu
Lab Section: 021
Assignment: Lab 2
Group: John Doe, Jane Doe, and Joe Doe
I acknowledge all content is original.

Tar ball command: tar -cvzf name.tgz *.c *.pdf *.txt

The tar command will compress all files into a .tgz file with all .c .pdf, and .txt files in that directory. Do not include unnecessary files! The .c files be named as follows lab#_part#.c and the postlab#.pdf/postlab#.txt.

For Example:
lab2.c
postlab2.pdf
postlab2.txt