Created
September 1, 2012 14:11
-
-
Save danielpclark/3574245 to your computer and use it in GitHub Desktop.
Some amateur encryption software I wrote some time before 2005
This file contains 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
#!/usr/bin/python | |
#amencrypt.py | |
# Author: Daniel P. Clark | |
# Some amateur encryption software I wrote some time before 2005 | |
import sys, string, time | |
one = "" | |
two = "" | |
three = "" | |
four = "" | |
five = "" | |
file2write = "newfile.txt" | |
infilel = [] | |
def encwriter(): | |
global one, two, three, four, five | |
print "Encryption code is all integers, no letters or other characters." | |
enc_code = raw_input("Enter encryption code: ") | |
if len(enc_code) < 9: | |
print "CODE TOO SHORT!" | |
time.sleep(2) | |
print "\n" * 30 | |
return | |
else: | |
one = str(abs(int(enc_code[0:2]))) | |
two = str(abs(int(enc_code[2:5]))) | |
three = str(abs(int(enc_code[4:6]))) | |
four = str(abs(int(enc_code[5:8]))) | |
five = str(abs(int(enc_code[8:])) + 10) | |
print "\n" * 30 | |
outputfile = open(file2write, "a") | |
print "6ft dan's Text Encryptor!" | |
print"" | |
outputfile.write("#" + "\n") | |
while 1: | |
text = raw_input("| ") | |
if text in ("quit", "QUIT", "EXIT", "exit"): | |
break | |
else: | |
for x in range(len(text)): | |
outputfile.write(str(((((ord(text[x]) * int(one)) + int(two)) * int(three)) + int(four)) * int(five)) + ", ") | |
outputfile.write("\n") | |
outputfile.close() | |
print "\n" * 30 | |
def encreader(): | |
global one, two, three, four, five | |
print "Encryption code is all integers, no letters or other characters." | |
enc_code = raw_input("Enter encryption code: ") | |
if len(enc_code) < 9: | |
print "CODE TOO SHORT!" | |
time.sleep(2) | |
print "\n" * 30 | |
return | |
else: | |
one = str(abs(int(enc_code[0:2]))) | |
two = str(abs(int(enc_code[2:5]))) | |
three = str(abs(int(enc_code[4:6]))) | |
four = str(abs(int(enc_code[5:8]))) | |
five = str(abs(int(enc_code[8:])) + 10) | |
print "\n" * 30 | |
inputfile = open(file2write, "r") | |
for line in inputfile.readlines(): | |
if line[0] == '#': | |
print "#" + "-" * 78 | |
else: | |
infilel = string.split(line[:-3], ",") | |
for x in range(len(infilel)): | |
infilel[x] = chr(int(((((float(infilel[x]) / int(five)) - int(four)) / int(three)) - int(two)) / int(one))) | |
infilel = string.join(infilel, "") | |
print infilel | |
raw_input("\nHit enter to continue! ") | |
inputfile.close() | |
print "\n" * 30 | |
def runNow(): | |
print "\n" * 30 | |
while 1: | |
print "Welcome to 6ft dan's Text Encryptor and Decryptor! Version 0.1" | |
print "" | |
print " Command | About" | |
print " |" | |
print " File | For choosing a file to work with" | |
print " Read | Reads/Decrypts chosen file" | |
print " Write | Writes/Encrypts to end of chosen file" | |
option = raw_input(": ") | |
option = string.lower(option) | |
if option == "read": | |
print "\n" * 30 | |
encreader() | |
elif option == "write": | |
print "\n" * 30 | |
encwriter() | |
elif option == "file": | |
print "\n" * 30 | |
file2write = raw_input("What is the name of the file you'd like to use? ") | |
print "\n" * 30 | |
else: | |
break | |
try: | |
runNow() | |
except ValueError: | |
continue | |
except: | |
print "Error. Exiting.", sys.exc_type | |
print "Thank you for using 6ft Dan Software!" | |
print "Visit our website at http://6ftdan.com/" | |
time.sleep(3) | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment