Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import argv
- if len(argv) <= 1:
- exit("Synthax:\npython3 script.py encodedInvisibleString\nYou can happen other chars as well, they'll just be ignored")
- def textFromBits(bits, encoding='utf-8', errors='surrogatepass'):
- n = int(bits, 2)
- return n.to_bytes((n.bit_length() + 7) // 8, 'big').decode(encoding, errors) or '\0'
- # Used to separate bits
- #zws = "\u200b" # Zero width space
- # Represents a one
- zwj = "\u200d" # Zero width joiner
- #zwj = "a" # Zero width joiner
- # Represents a zero
- zwnj = "\u200c" # Zero width non-joiner
- #zwnj = "b" # Zero width non-joiner
- message = ""
- for arg in argv[1:]:
- message += arg + " "
- message = message[:-1]
- msg = ""
- for c in message:
- if c in zwj or c in zwnj:
- msg += c
- message = msg
- print("Zero width message (len {}): \"{}\"".format(len(message), message))
- msgBin = "".join(["1" if c in zwj else "0" for c in message])
- #print("Binary message: " + msgBin)
- origMsg = textFromBits(msgBin)
- print("Original message: " + origMsg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement