Created
October 20, 2016 05:03
-
-
Save binary10/9ed602dd5d1b2e4335ec1c51bb5b5a64 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
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