Created
March 16, 2016 23:43
-
-
Save andwn/43936243184e9b100c1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Hides values as invisible spaces in strings | |
| # Usage: ht.py e string to encode | |
| # or: ht.py d string to decode (remove formatting) | |
| from random import randint | |
| import sys, re | |
| inv_str = [ u"\uFEFF", u"\uFE00" ] | |
| #inv_str = [ "{TEST}", "{HI}", "{BYE}" ] | |
| def encode(str): | |
| strList = str.split(' ') | |
| for i in range(len(strList)): | |
| s = strList[i] | |
| if len(s) < 3: | |
| continue | |
| pos = randint(1, len(s) - 1) | |
| inv = inv_str[randint(0, len(inv_str) - 1)] | |
| strList[i] = s[:pos] + inv + s[pos:] | |
| return ' '.join(strList) | |
| def decode(str): | |
| for inv in inv_str: | |
| str = re.sub(re.escape(inv), '', str) | |
| return str | |
| if sys.argv[1] == 'e': | |
| print encode(' '.join(sys.argv[2:])) | |
| elif sys.argv[1] == 'd': | |
| print decode(' '.join(sys.argv[2:])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment