Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def b64_encode(decimal):
- char_lower = 'abcdefghijklmnopqrstuvwxyz'
- char_upper = char_lower.upper()
- char_num = '0123456789'
- char_special = '=/'
- char_b64 = char_upper+char_lower+char_num+char_special
- char_b64 = list(char_b64)
- val = decimal
- val_mod = []
- val_return = []
- if val <= 64:
- return char_b64[val % 64]
- else:
- while val > 64:
- val_mod.append(val % 64)
- val = int(val / 64)
- if val < 64:
- val_mod.append(val)
- for i in reversed(val_mod):
- val_return.append(char_b64[i])
- return ''.join(val_return)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement