Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def getEqCh(n):
- rem24 = (n * 8) % 24
- return int((24 - rem24) % 24 / 8)
- def cutStr(str, step):
- res = []
- delta = step
- for i in range(0, len(str), delta):
- res.append(str[i:step])
- step += delta
- return res
- s = open('base64.in')
- arr = s.readlines()
- s.close()
- arr[0], arr[1] = int(arr[0]), arr[1][:-1]
- n = len(arr[1].split())
- newBinArr = (cutStr(''.join([format(int(bin(int(arr[1].split()[i], 16))[2:], 2), '#010b')[2:] for i in range(n)]), 6))
- while len(newBinArr[-1]) < 6:
- newBinArr[-1] += '0'
- result = ""
- alphabet = list("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
- for item in newBinArr:
- result += alphabet[int(item, 2)]
- result += getEqCh(arr[0]) * '='
- f = open('base64.out', 'w')
- f.write(f"{result}")
- f.close()
Add Comment
Please, Sign In to add comment