Permalink
Browse files

Renamed fp variables to fo.

  • Loading branch information...
asweigart committed Feb 25, 2013
1 parent 12c6589 commit b38e5dd12af4d459330d582d09c971f922d661b8
Showing with 24 additions and 24 deletions.
  1. +6 −6 makeRsaKeys.py
  2. +7 −7 makeWordPatterns.py
  3. +8 −8 rsaCipher.py
  4. +3 −3 vigenereDictionaryHacker.py
View
@@ -56,16 +56,16 @@ def makeKeyFiles(name, keySize):
print()
print('The public key is a %s and a %s digit number.' % (len(str(publicKey[0])), len(str(publicKey[1]))))
print('Writing public key to file %s_pubkey.txt...' % (name))
- fp = open('%s_pubkey.txt' % (name), 'w')
- fp.write('%s,%s,%s' % (keySize, publicKey[0], publicKey[1]))
- fp.close()
+ fo = open('%s_pubkey.txt' % (name), 'w')
+ fo.write('%s,%s,%s' % (keySize, publicKey[0], publicKey[1]))
+ fo.close()
print()
print('The private key is a %s and a %s digit number.' % (len(str(publicKey[0])), len(str(publicKey[1]))))
print('Writing private key to file %s_privkey.txt...' % (name))
- fp = open('%s_privkey.txt' % (name), 'w')
- fp.write('%s,%s,%s' % (keySize, privateKey[0], privateKey[1]))
- fp.close()
+ fo = open('%s_privkey.txt' % (name), 'w')
+ fo.write('%s,%s,%s' % (keySize, privateKey[0], privateKey[1]))
+ fo.close()
# If makeRsaKeys.py is run (instead of imported as a module) call
View
@@ -27,9 +27,9 @@ def getWordPattern(word):
def main():
allPatterns = {}
- fp = open('dictionary.txt')
- wordList = fp.read().split('\n')
- fp.close()
+ fo = open('dictionary.txt')
+ wordList = fo.read().split('\n')
+ fo.close()
for word in wordList:
# Get the pattern for each string in wordList.
@@ -42,10 +42,10 @@ def main():
# This is code that writes code. The wordPatterns.py file contains
# one very, very large assignment statement.
- fp = open('wordPatterns.py', 'w')
- fp.write('allPatterns = ')
- fp.write(pprint.pformat(allPatterns))
- fp.close()
+ fo = open('wordPatterns.py', 'w')
+ fo.write('allPatterns = ')
+ fo.write(pprint.pformat(allPatterns))
+ fo.close()
if __name__ == '__main__':
View
@@ -94,9 +94,9 @@ def decryptMessage(encryptedBlocks, messageLength, key, blockSize=DEFAULT_BLOCK_
def readKeyFile(keyFilename):
# Given the filename of a file that contains a public or private key,
# return the key as a (n,e) or (n,d) tuple value.
- fp = open(keyFilename)
- content = fp.read()
- fp.close()
+ fo = open(keyFilename)
+ content = fo.read()
+ fo.close()
keySize, N, EorD = content.split(',')
return (int(keySize), int(N), int(EorD))
@@ -121,9 +121,9 @@ def encryptAndWriteToFile(messageFilename, keyFilename, message, blockSize=DEFAU
# Write out the encrypted string to the output file.
encryptedContent = '%s_%s_%s' % (len(message), blockSize, encryptedContent)
- fp = open(messageFilename, 'w')
- fp.write(encryptedContent)
- fp.close()
+ fo = open(messageFilename, 'w')
+ fo.write(encryptedContent)
+ fo.close()
# Also return the encrypted string.
return encryptedContent
@@ -135,8 +135,8 @@ def readFromFileAndDecrypt(messageFilename, keyFilename):
# Read in the message length and the encrypted message from the file.
- fp = open(messageFilename)
- content = fp.read()
+ fo = open(messageFilename)
+ content = fo.read()
messageLength, blockSize, message = content.split('_')
messageLength = int(messageLength)
blockSize = int(blockSize)
@@ -16,9 +16,9 @@ def main():
def hackVigenere(ciphertext):
- fp = open('dictionary.txt')
- words = fp.readlines()
- fp.close()
+ fo = open('dictionary.txt')
+ words = fo.readlines()
+ fo.close()
for word in words:
word = word.strip() # remove the newline at the end

0 comments on commit b38e5dd

Please sign in to comment.