This commit is contained in:
Miroslav Stampar
2023-12-13 14:12:17 +01:00
parent 6dd383fd72
commit 53b8a9583e
3 changed files with 74 additions and 54 deletions

View File

@@ -135,6 +135,23 @@ def dejsonize(data):
return json.loads(data)
def rot13(data):
"""
Returns ROT13 encoded/decoded text
>>> rot13('foobar was here!!')
'sbbone jnf urer!!'
>>> rot13('sbbone jnf urer!!')
'foobar was here!!'
"""
# Reference: https://stackoverflow.com/a/62662878
retVal = ""
alphabit = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
for char in data:
retVal += alphabit[alphabit.index(char) + 13] if char in alphabit else char
return retVal
def decodeHex(value, binary=True):
"""
Returns a decoded representation of provided hexadecimal value