-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise_03
More file actions
executable file
·28 lines (20 loc) · 790 Bytes
/
exercise_03
File metadata and controls
executable file
·28 lines (20 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
# Copyright 2014 Carl Winbäck. See the COPYING file at the top-level directory
# of this distribution.
from libpals.util import xor_singlechar, xor_find_singlechar_key
input_string = '1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736'
ciphertext = bytes.fromhex(input_string)
result = xor_find_singlechar_key(ciphertext)
plaintext = result['plaintext']
output_message = """SET 01 CHALLENGE 03: Single-character XOR Cipher
Input: {}
Key:
Decimal: {}
Hex: {}
ASCII: {}
Message: {}"""
print(output_message.format(input_string,
result['key'],
hex(result['key']),
chr(result['key']),
str(object=plaintext, encoding='ascii')))