Overview
This week you will work in groups of 4 to complete a project to convert a file into Base64.
Thursday, December 7th
Classwork / Homework
Both class and homework time today will be dedicated to your Base64 project. The only thing I want to add today is the following requirement:
Use the function gitbits(byte, num, pos) when converting from binary to base64 and back.
Make sure you understand the one line expression that this function returns, and that you could apply it by hand with pencil and paper, since that is exactly what you will be asked to do in a quiz at the end of this project.
Tuesday, December 5th
Classwork / Homework
You will begin class today with a short quiz to make sure you did your homework. After the quiz, you will have the rest of the class to work on this week's project.
NOTE: I will not be here today during 5th period, so Mr. Daniels will be here for me. He will give you the quiz and then let you start on your project.
Our friend José Ejemplo wrote an improved version of the group chooser
program (which you can see
here) that
we can use to select groups of arbitrary size. Running
$ ./choose_groups P4.dat 4
yielded:
Abi, Amelie, Anupama and Noah
Adrian, Jake, Kiersten and Conrad
Blu, Jack, Alex and Alessandra
Erica, Toby, Evan and Grant
A run of $ ./choose_groups P5.dat 4
gave us:
Mayah, Jonathan, Rockwell and Udval
Gabriel, Dylan, Donovan and Colin
Sean, Yuri, Evan and Sam
Timh, Daniel, Luka and Fatima
These will be the groups for the project this week.
Project Challenge: RFC 4648 Encoding and Decoding
The challenge is to write two Python programs named ToBase64.py
and FromBase64.py
.
The first takes an arbitrary file as input and converts it into an RFC 4648 string, sending it to standard output.
For example, if we have a source file named justbits.txt
containing the single line of text:
It's all just bits!
Running:
$ python3 ToBase64.py justbits.txt
will print:
SXQncyBhbGwganVzdCBiaXRzIQo=
to the screen. The second program will reverse this operation. If we have the
above string stored in a file named justbits_encoded.txt
, running:
$ python3 FromBase64.py justbits_encoded.txt
will print: It's all just bits!
to our screen.
This project has several moving parts
, which is why I am putting you in
groups of four. You need to break down the task, and assign (pairs, perhaps?)
responsible people to each part of the task. Then you have to work together to
assemble the parts.
To get started, I suggest you try to address the following questions:
-
Do I understand how to apply RFC 4648
by hand
to a sequence of input bytes to generate a Base64 encoded output? - How many input bytes are required? How many output characters will this input produce?
- Can I express this requirement in doctests for a function in Python to convert the input bytes into the desired output text?
- What do we need to do to handle any leftover bytes at the end of the process?
This project will be due by Saturday, December 9th at 11:59 pm.
Resources
The following resources, used intelligently, provide you with much of what you need to accomplish this programming task: