Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def symbEncode(x):
- if x < 26:
- return chr(x + 65)
- elif x < 52:
- return chr(x + 97 - 26)
- elif x < 62:
- return chr(x + 45 - 26*2)
- elif x == 62:
- return "+"
- else:
- return "/"
- x = 21
- print(symbEncode(x))
- def sybmDecode(y):
- n = ord(y)
- if n == 43:
- return "{0:b}".format(63).zfill(6)
- elif n == 47:
- return "{0:b}".format(62).zfill(6)
- elif n < 58:
- return "{0:b}".format(n - 48 + 52).zfill(6)
- elif n < 91:
- return "{0:b}".format(n - 65).zfill(6)
- else:
- return "{0:b}".format(n - 97 + 26).zfill(6)
- def sybmDecode2(y):
- n = ord(y)
- if n == 43:
- return bin(63)[2:].zfill(6)
- elif n == 47:
- return bin(62)[2:].zfill(6)
- elif n < 58:
- return bin(n - 48 + 52)[2:].zfill(6)
- elif n < 91:
- return bin(n - 65)[2:].zfill(6)
- else:
- return bin(n - 97 + 26)[2:].zfill(6)
- y = "B"
- print(sybmDecode2(y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement