diff --git a/144/rot13.py b/144/rot13.py new file mode 100755 index 0000000..0c091cf --- /dev/null +++ b/144/rot13.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import sys +import string + +rawInput = sys.stdin.read() +output = "" + +for c in rawInput: + if c in string.ascii_lowercase: + letters = string.ascii_lowercase + elif c in string.ascii_uppercase: + letters = string.ascii_uppercase + else: + output += c + continue + + i = letters.index(c) + if i > 12: + i -= 13 + else: + i += 13 + + output += letters[i] + +print(output) diff --git a/156/decode.py b/156/decode.py new file mode 120000 index 0000000..5cd9215 --- /dev/null +++ b/156/decode.py @@ -0,0 +1 @@ +../22/decode.py \ No newline at end of file diff --git a/166/a.txt b/166/a.txt new file mode 100644 index 0000000..94bac77 --- /dev/null +++ b/166/a.txt @@ -0,0 +1 @@ +gAAAAABgUAIWIvSiR0W23DAHIK5DX6Y4BvwES94M_XdDcNAquhp-A0D2z8n812YEXaSD9WhoweBh2cm5Wa0cqzuW0Kc7fOct0OJnpOmVF8A91j0Hx4dKtvk3l5ghPT71Y7GxErPRyJUs diff --git a/166/ende.py b/166/ende.py new file mode 100755 index 0000000..e7b5b30 --- /dev/null +++ b/166/ende.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 + +import sys +import base64 +from cryptography.fernet import Fernet + + + +usage_msg = "Usage: "+ sys.argv[0] +" (-e/-d) [file]" +help_msg = usage_msg + "\n" +\ + "Examples:\n" +\ + " To decrypt a file named 'pole.txt', do: " +\ + "'$ python "+ sys.argv[0] +" -d pole.txt'\n" + + + +if len(sys.argv) < 2 or len(sys.argv) > 4: + print(usage_msg) + sys.exit(1) + + + +if sys.argv[1] == "-e": + if len(sys.argv) < 4: + sim_sala_bim = input("Please enter the password:") + else: + sim_sala_bim = sys.argv[3] + + ssb_b64 = base64.b64encode(sim_sala_bim.encode()) + c = Fernet(ssb_b64) + + with open(sys.argv[2], "rb") as f: + data = f.read() + data_c = c.encrypt(data) + sys.stdout.write(data_c.decode()) + + +elif sys.argv[1] == "-d": + if len(sys.argv) < 4: + sim_sala_bim = input("Please enter the password:") + else: + sim_sala_bim = sys.argv[3] + + ssb_b64 = base64.b64encode(sim_sala_bim.encode()) + c = Fernet(ssb_b64) + + with open(sys.argv[2], "r") as f: + data = f.read() + data_c = c.decrypt(data.encode()) + sys.stdout.buffer.write(data_c) + + +elif sys.argv[1] == "-h" or sys.argv[1] == "--help": + print(help_msg) + sys.exit(1) + + +else: + print("Unrecognized first argument: "+ sys.argv[1]) + print("Please use '-e', '-d', or '-h'.") + diff --git a/186/cat.jpg b/186/cat.jpg new file mode 100644 index 0000000..7351fbc Binary files /dev/null and b/186/cat.jpg differ diff --git a/22/decode.py b/22/decode.py new file mode 100755 index 0000000..b1c5837 --- /dev/null +++ b/22/decode.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import sys + +rawInput = sys.stdin.readlines() +splitInput = [l.strip() for l in rawInput] + +for c in splitInput: + try: + int(c) + is_int = True + except ValueError: + is_int = False + assert is_int, "Input must be in decimal form, and separated by newlines" + +rawOutput = [] +for c in splitInput: + c2 = chr(int(c)) + rawOutput.append(c2) + +output = "" +for c in rawOutput: + output += c + +print(output)