|
|
|
@ -1,5 +1,6 @@
|
|
|
|
import datetime
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Exercise00:
|
|
|
|
class Exercise00:
|
|
|
|
STUDENT_NAME = "Eggert Jung"
|
|
|
|
STUDENT_NAME = "Eggert Jung"
|
|
|
|
|
|
|
|
|
|
|
|
@ -38,26 +39,13 @@ class Exercise00:
|
|
|
|
def __str__(self):
|
|
|
|
def __str__(self):
|
|
|
|
return b64_enc(self.__txt)
|
|
|
|
return b64_enc(self.__txt)
|
|
|
|
|
|
|
|
|
|
|
|
def b64_enc_map(index):
|
|
|
|
|
|
|
|
if(index >= 0 and index < 26):
|
|
|
|
|
|
|
|
return chr(index + 0x41) # A-Z
|
|
|
|
|
|
|
|
elif(index >= 26 and index < 52):
|
|
|
|
|
|
|
|
return chr(index + 0x61 - 26) # a-z
|
|
|
|
|
|
|
|
elif(index >= 52 and index < 62):
|
|
|
|
|
|
|
|
return chr(index + 0x30 - 52) # 0-9
|
|
|
|
|
|
|
|
elif(index == 62):
|
|
|
|
|
|
|
|
return '+'
|
|
|
|
|
|
|
|
elif(index == 63):
|
|
|
|
|
|
|
|
return '/'
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return '='
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def b64_enc(str):
|
|
|
|
def b64_enc(str):
|
|
|
|
res = ""
|
|
|
|
res = ""
|
|
|
|
|
|
|
|
b64_map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
|
|
|
for c in [(str[i:i+3]) for i in range(0, len(str), 3)]:
|
|
|
|
for c in [(str[i:i+3]) for i in range(0, len(str), 3)]:
|
|
|
|
c = bytes(c, 'utf-8')
|
|
|
|
c = bytes(c, 'utf-8')
|
|
|
|
bits = [-1,-1,-1,-1]
|
|
|
|
bits = [64, 64, 64, 64]
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
bits[0] = (c[0] & 0xFC) >> 2
|
|
|
|
bits[0] = (c[0] & 0xFC) >> 2
|
|
|
|
|
|
|
|
|
|
|
|
@ -71,7 +59,7 @@ def b64_enc(str):
|
|
|
|
except IndexError:
|
|
|
|
except IndexError:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
for i in range(4):
|
|
|
|
for i in range(4):
|
|
|
|
res = res + b64_enc_map(bits[i])
|
|
|
|
res = res + b64_map[bits[i]]
|
|
|
|
return res
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -79,11 +67,15 @@ if __name__ == "__main__":
|
|
|
|
import argparse
|
|
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('FILE', help="The input positional parameter.")
|
|
|
|
parser.add_argument('FILE', help="The input positional parameter.")
|
|
|
|
parser.add_argument('-b', '--bool', action='store_true', help="An optional boolean flag (Default: False).")
|
|
|
|
parser.add_argument('-b', '--bool', action='store_true',
|
|
|
|
parser.add_argument('-f', '--float', default=0.0, type=float, help="An optional parameter of type float (Default: 0.0).")
|
|
|
|
help="An optional boolean flag (Default: False).")
|
|
|
|
parser.add_argument('-i', '--int', default=0, type=int, help="An optional parameter of type int (Default: 0).")
|
|
|
|
parser.add_argument('-f', '--float', default=0.0, type=float,
|
|
|
|
|
|
|
|
help="An optional parameter of type float (Default: 0.0).")
|
|
|
|
|
|
|
|
parser.add_argument('-i', '--int', default=0, type=int,
|
|
|
|
|
|
|
|
help="An optional parameter of type int (Default: 0).")
|
|
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
|
print("input: {FILE}\n--bool {bool}\n--float {float}\n--int {int}".format(**args.__dict__))
|
|
|
|
print(
|
|
|
|
|
|
|
|
"input: {FILE}\n--bool {bool}\n--float {float}\n--int {int}".format(**args.__dict__))
|
|
|
|
|
|
|
|
|
|
|
|
exit(42)
|
|
|
|
exit(42)
|
|
|
|
|