Skip to content

Instantly share code, notes, and snippets.

@binary10
Created October 20, 2016 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binary10/9ed602dd5d1b2e4335ec1c51bb5b5a64 to your computer and use it in GitHub Desktop.
Save binary10/9ed602dd5d1b2e4335ec1c51bb5b5a64 to your computer and use it in GitHub Desktop.
def scramble2Decrypt(cipherText):
halfLength = len(cipherText) // 2
oddChars = cipherText[:halfLength]
evenChars = cipherText[halfLength:]
plainText = ""
for i in range(halfLength):
plainText = plainText + evenChars[i]
plainText = plainText + oddChars[i]
if len(oddChars) < len(evenChars):
plainText = plainText + evenChars[-1]
return plainText
def scramble2Encrypt(plainText):
evenChars = ""
oddChars = ""
charCount = 0
for ch in plainText:
if charCount % 2 == 0:
evenChars = evenChars + ch
else:
oddChars = oddChars + ch
charCount = charCount + 1
cipherText = oddChars + evenChars
return cipherText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment