lab5 - oddString = cipherText[:len(cipherText)//2]...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
def railFence (text): evenChars = "" oddChars = "" charCount = 0 for ch in text: if charCount % 2 == 0: evenChars = evenChars + ch else: oddChars = oddChars + ch charCount = charCount + 1 cipherText = oddChars + evenChars return cipherText def stripSpaces (myString): return (myString.replace (" ", "")) def transpositionFlip (text): evenChars = "" oddChars = "" charCount = 0 for ch in text: if charCount % 2 == 0: evenChars = evenChars + ch else: oddChars = oddChars + ch charCount = charCount + 1 cipherText = evenChars + oddChars return cipherText def transpositionReflip (cipherText): if len(cipherText) %2 ==1: oddString = cipherText[:len(cipherText)//2+1] #splice the first half evenString = cipherText[len(cipherText)//2+1:] #splice the second half elif len(cipherText) %2==0:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: oddString = cipherText[:len(cipherText)//2] evenString = cipherText[len(cipherText)//2:] plainText = '' for i in range(len(cipherText)//2): plainText = plainText + oddString[i] plainText = plainText + evenString[i] if len(evenString) < len(oddString): plainText = plainText + oddString[-1] return plainText def asciiEqual(): for i in range (700): acc = 0 for ch in str(i): ord(ch) acc = acc + ord(ch) if acc == i: return str (i) def subEncrypt ( plainText, key): alphabet = "abcdefghijklmnopqrstuvwxyz1234567890" plainText = plainText.replace (" ", "").lower() cipherText = "" for ch in plainText: idx = alphabet.find(ch) cipherText = cipherText + key[idx] return cipherText...
View Full Document

This note was uploaded on 04/26/2011 for the course CPS 324 taught by Professor Safa during the Spring '11 term at Dickinson.

Page1 / 2

lab5 - oddString = cipherText[:len(cipherText)//2]...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online