Reputation: 31
For my beginners course Python I got the following assignment:
Write a program that decrypts messages in the following format:
<encryption_algorithm>:<key>:<message>
Example: caesar:42:01110010 10001111 10010110 10010110 10011001
The messages are encoded as binary strings with length 8 and have to be converted to ASCII. The messages can use Caesar and Vigenère encryption logarithms. It is not allowed to use the built-in functionality int(n,2). Tips: use string.split() when reading the input file. Start by parsing the input file.
I actually don't know where to start. Writing a function to convert binary in to decimals and vice versa? Write a Caesar decrypt and encrypt code?
Upvotes: 0
Views: 192
Reputation: 3265
I am not going to do the assignment for you but what I can do is give you a hint:
01110010
is 0 * 2**0 + 1 * 2**1 + 0 * 2**2...
Each bit needs to be multiplied by the appropriate power of 2, just like base 10:
1234567
is 7 * 10**0 + 6 * 10**1 + 5 * 10**2
You probably need a loop, but before that, you need to use the hint given in your assignment...
You can use help(str.split)
if you have a problem with that
Upvotes: 1