Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions examples/session03/cipher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import random

alphabet = "abcdefghijklmnopqrstuvwxyz "

alphabet_list = list(alphabet)

# Create a new copy of alphabet list
cipher_list = list(alphabet_list)

# This should be a list in order
print(cipher_list)

message_text = "what has dates and sundays but cannot be eaten"

random.shuffle(cipher_list)

# This should be random now
print(cipher_list)

cipher_text = ""

for x in message_text:
index = alphabet_list.index(x)
cipher_char = cipher_list[index]
cipher_text += cipher_char

# This is what
print(cipher_text)
23 changes: 23 additions & 0 deletions examples/session03/decipher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This is the file for the deciphering partner.

alphabet = "abcdefghijklmnopqrstuvwxyz "

alphabet_list = list(alphabet)

# Copy and paste the cipher list from your partner below,
# instead of the empty list.
cipher_list = ['v', 'w', 'u', 'q', 'k', 'm', 'g', 'z', 'l', 'n', 'e', ' ', 'd', 'b', 'x', 'y', 'i', 't', 'f', 'h', 'r', 'c', 'j', 'a', 'p', 's', 'o']


# copy and paste the cipher_text from your partner in slack
# and assign it to the variable new_cipher_text
new_cipher_text = "jzvhozvfoqvhkfovbqofrbqvpfowrhouvbbxhowkokvhkb"

decrypt_text = ""

for y in new_cipher_text:
index = cipher_list.index(y)
decrypt_char = alphabet_list[index]
decrypt_text += decrypt_char

print(decrypt_text)
4 changes: 4 additions & 0 deletions test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test
test2
test3
test4