Skip to content

Instantly share code, notes, and snippets.

@nick3499
Last active May 10, 2022 00:05
Show Gist options
  • Save nick3499/aa82c6704c2c889f26d69540f9338583 to your computer and use it in GitHub Desktop.
Save nick3499/aa82c6704c2c889f26d69540f9338583 to your computer and use it in GitHub Desktop.
Vowel Encoding: Python 3: 'vowel encoding' changes vowels to numbers in order to obfuscate context
#!/bin/python3
'''Use encoding to disguise message by converting vowels to numbers.'''
# Permission granted under “The MIT License” (open source)
def encode(s: str) -> str:
enc = { 'a': '1', 'e': '2', 'i': '3', 'o': '4', 'u': '5' }
return ''.join(enc[x] if x in enc else x for x in s)
def decode(s: str) -> str:
dec = { '1': 'a', '2': 'e', '3': 'i', '4': 'o', '5': 'u' }
return ''.join(dec[x] if x in dec else x for x in s)
@nick3499
Copy link
Author

nick3499 commented May 9, 2022

The script could be executed locally in a Python shell using requests.get():

>>> from requests import get
>>> url = 'https://gist.githubusercontent.com/nick3499/aa82c6704c2c889f26d69540f9338583/raw/dd83c9678b36fa68411da97e070108e68c8d286e/vowel_encoding.py'
>>> exec(get(url).text)
>>> encode('hello')
'h2ll4'
>>> decode('h2ll4')
'hello'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment