Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with this question Instructions Inside the file there is 12 ciphertexts (shown in hexadecimal). They were all encrypted with the same key using

Please help with this question

Instructions

Inside the file there is 12 ciphertexts (shown in hexadecimal). They were all encrypted with the same key using the one-time-pad. Your task is to decrypt the 12th (last) one.

To help, the hash of the plaintext corresponding to the 12th ciphertext is provided (along with the Python code that generated it). Also, a hash of the key (pad) used for your challenge is also included. You can use these to verify that your answer is correct.

All of the plaintexts (and ciphertexts) have 60 characters in them. The plaintexts are fragments of a body of English text. A given plaintext may start/end mid-word. The words may contain proper nouns. The alphabet used for the plaintext are elements of the following (not including the double quotes):

"! '(),.12356789:?abcdefghijklmnopqrstuvwxyz"

Note that a space is included here. There are NO newline characters.

To help, I have included the Python code used to generate the challenge (more or less).

Submit a single plaintext file called otp-XXX.txt, where XXX is your 3-digit challenge number (like 301). Your file will consists of the plaintext of the 12th ciphertext in your challenge. Do NOT put quotes around your plaintext. It should have 60 characters in it (don't use HEX for this). For example, the example shown would have the single line (WITHOUT the quotes... I included them here to illustrate that there is a space at the end).

"ces of hundreds of yards. it was as though the windmill had "

When we test your solution, we'll read the file and compare the first 60 characters in your file with the expected solution.

challenge number 375

twelve-time-pad-c375

cbafe8a4a29f375d370cb2177109f993b8b95bfc3f792117baec38f782e94419f0831c1d1707c2519d7c11b41f1b8d01e662685ca72dfbaef2515b50
d2a1bca3e4de38197b05bc0a3809f584f3b958fa347f2916f8b824b9d5f5451febc659010211d54a8c3201b41a48c309b0636e4bb662efb2a74c5c11
9cafbcafed8b355d3714b5146709e693e5f04aed77652253fbad39e082ee4413e08d4f555203cf4a8a344ef11201c60de67e614fe279e8b3e9565117
c8aebca7eb903d577213ae4d3448fa92b6ed51fc777a2205f3ec38ff82eb450ef7935957521d874b883842b31b0fd806e666604ca72deaa8f3571f12
d3b4e5e0a29f375d3709fd066646f598f3fd19fb3e623916e4a02eb782e94415f0c64f16071ac3038d3511a50b1acf0da22a6844e262f1a5a748501d
d5b2bcbbe38d79517212b8416041f582b6ed51fc77662203e3a036edcbf2425cec801c0d1a11874086290ca50c118d0bae636c4cae74bda2e8535315
d9e6f9adf08a31173709fd097148e692b6f65fb9237e2853e5a038edcafb5910a3874f101300ce409a7c0db75e1cc50de6797d5fb268f3a5e84a4c50
9caef9ecea9b355d3715ad416041f1d6f5ec4bed367f2353f9aa77edcaf80c1ee6821c181c10874b802f42b4070dde44e6636f0aa774f8b2a74b5715
dfa3efeced98794d7f05fd097148e693e4ea17b9237e2400b6bb36ea82f44218e68358591354c04c8d300bba1b48de0baf6f6749a721bda0e95b1f19
d4e6faa3f0933c5d3701fd167b5bf892bab94ef138652853f3b43eead6f8421fe6c6581c0211c9478c3842be1048d900a32a6543a468bdaee11f5604
d8a3eebff69f375d3714b5086709f293f3f550f730296d07fea524b9c0ef4919f9831059051cce40817c0ab00d48d91aa77c6c46ae68f9e1e14d501d
9cb1f5a2f69b2b153717b5047a09fd82e5b954f824622801e5ec34f6d7f1485cf0855d0b1111cb5ac92c10be1d1ddf0de66c6645a62de9aea74c4a00

hashlib.sha3_224(msgs[-1].encode('utf-8')).hexdigest()
3e3285be2df8bb2cbd9beb128e819d3c6514ff609bdfee61a4c2e47d

hashlib.sha3_224(pad).hexdigest()
0c974b4a617ae4d6ca5b0625289c674a7d0da4285e99ff50828dffa7

Python Code (to generate the challenges)

import os, random, hashlib
import HIDDEN


number_of_students = 2
offset = 100

random.seed(HIDDEN.seed)
h = hashlib.sha3_224()

with open(HIDDEN.text) as f:
text = f.read()

start = HIDDEN.start
end = len(text) - HIDDEN.end

fname = 'twelve-time-pad-'
pname = 'ttp-plaintext-'

def encrypt(pad,msg):
return bytes([x^ord(y) for (x,y) in zip(pad,msg)]).hex()


for challenge in range(offset, offset + number_of_students):
# grab some plaintext messages
msgs = [ text[a:a+60] for a in [random.randint(start,end) for i in range(12)] ]

# grab a pad (key for encryption)
pad = os.urandom(60)

# encrypt each plaintext with the pad
ctxts = [encrypt(pad, m) for m in msgs]

# output everything to files
with open( f'{pname}c{challenge:03}.txt' ,'w') as plain, open( f'{fname}c{challenge:03}.txt', 'w') as cipher:
for msg in msgs: # print plaintext messages (as text)
print(repr(msg), file=plain)
print("-"*60, file=plain)
for msg in msgs: # print plaintext messages (in hex)
print(bytes([ord(y) for y in msg]).hex(), file=plain)
print("-"*60, file=plain)

print(pad.hex(), file=plain) # print the pad in hex
print("-"*60, file=plain)

for c in ctxts: # print the ciphertext messages
print(c, file=cipher)
print(c, file=plain)


# some information to let you test your answer
print(" hashlib.sha3_224(msgs[-1].encode('utf-8')).hexdigest()", file=cipher)
print(hashlib.sha3_224(msgs[-1].encode('utf-8')).hexdigest(), file=cipher)
print(" hashlib.sha3_224(pad).hexdigest()", file=cipher)
print(hashlib.sha3_224(pad).hexdigest(), file=cipher)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

what information privacy principles have been breached,

Answered: 1 week ago