Should be completed by Wednesday, April 23rd
We are rapidly approaching the end of the semester, and in just a week or two you are going to have to take the final exam. On that exam you will need to be able to describe the encodings of Sound and Picture files to me. It's never too early to start to review these concepts, and fortunately we can do this within the context of the textfiles that we have been working with lately.
On the very first day of the semester, while introducing this class, I mentioned the concept of Steganography.
Wikipedia defines :
"Steganography is the art and science of writing hidden messages in such a way that no one apart from the sender and intended recipient even realizes there is a hidden message. By contrast, cryptography obscures the meaning of a message, but it does not conceal the fact that there is a message. Today, the term steganography includes the concealment of digital information within computer files."
What we are going to do is arguably more cryptography than steganography, but today's lab is just a basic introduction to something we will spend more time considering over the next couple of lectures.
Suppose that you worked for the NSA (the National Security Agency - a cryptologic intelligence agency of the United States government - and your boss hands you the following, relatively large, text files:
He is convinced that these are more than simple text files (heck, the name is a dead giveaway) but he isn't quite sure how to go about analyzing them for their actual content. He hopes that you can help him out with this.
Download these files to your p: drive so that you have access to them during this lab.
Last minute reminder... Remember that Python is picky about data types when it comes to numbers and text files:
It is sometimes necessary to nest these to force things to print properly such as str( int( value ) )
Open up secrettext1.txt in a text editor of your choosing such as notepad or Microsoft Word. It is a fairly big file, so it might take a few seconds.
Look at the contents of the file:
[Q1] What is the value of the first line in the file? What might this represent? [Hint, take the value divided by 22050]
[Q2] Scroll down through the next 200 lines or so of the file. What kinds of numbers do you observe? What might these represent?
As you have probably guessed, this is a simple file that I created that textually represents a music file.
Write a method called readSoundFromTextFile()
Test this with the secrettext1.txt. Even if you don't recognize the song when you are done, you should realize that you have done this correctly.
[SIG1] Have a TA listen to your song and inspect your code to verify you have done this correctly.
Let's reverse this process.
Write a method called writeSoundToTextFile()
Test this with ANY sound sample of your choice. Save it's encoding to a text file called "<yourlastname>_Sound.txt" (For example, I created "Schafer_Sound.txt" )
I will use this for grading your lab.
[SIG2] [NOTE : I will not grade this during class but after class] When I check in your lab at the end, I will use your *_Sound.txt file to test if writeSoundToTextFile() worked properly and then sign here.
Open up secrettext2.txt in a text editor of your choosing such as notepad or Microsoft Word.
[Q3] What are the contents of the first line in the file? What might this represent?
[Q4] Scroll down through the next 200 lines or so of the file. What kinds of numbers do you observe? What might these represent?
Write a method called readPictureFromTextFile().
This one is a little bit more difficult because you have to worry about two dimensions. Think about the problem carefully and what changes happen under what conditions.
Test this with the secrettext2.txt. You should know if you have it done correctly!
[SIG3] Have a TA view your picture and inspect your code to verify you have done this correctly.
Again, let's reverse this process.
Write a method called writePictureToTextFile().
Test this with ANY Picture sample of your choice. Save it's encoding to a file called "<yourlastname>_Picture.txt" (For example, I created "Schafer_Picture.txt"
I will use this for grading your lab.
[SIG4] When I check in your lab at the end, I will use your *_Picture.txt file to test if writePictureToTextFile() worked properly and then sign here.
The files that I gave you are pretty big and represent fairly small sound/image files.
Brainstorm for a little bit.
[Q5] What kinds of things might you try that would make the text files smaller while still encoding these same sounds/pictures?
This week has a slightly different deliverable.
When you are already to go, make sure you have a directory named lab14 at the root level of your p: drive.
This directory should contain
When this is completed, hand in your signature form and at that point I will grade [SIG2] and [SIG4]