fixed pretty much most of it up

py3
Felix Pankratz 5 years ago
parent 71a107b407
commit 71b3fd1697

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys, string, types, hashlib, base64, re, urllib, binascii import sys, string, types, hashlib, base64, re, binascii
import operator import operator
from collections import Counter from collections import Counter
@ -89,7 +89,7 @@ def rot(inputString, amount):
resultChar = '' resultChar = ''
if char.isupper(): if char.isupper():
index = UPPER_LETTERS.index(char) index = UPPER_LETTERS.index(char)
resultChar = UPPER_LETTERS[(index + amount)%len(UPPER_LETTERS)] resultChar = UPPER_LETTERS[(index + amount) % len(UPPER_LETTERS)]
elif char.islower(): elif char.islower():
index = LOWER_LETTERS.index(char) index = LOWER_LETTERS.index(char)
resultChar = LOWER_LETTERS[(index + amount) % len(LOWER_LETTERS)] resultChar = LOWER_LETTERS[(index + amount) % len(LOWER_LETTERS)]
@ -162,7 +162,7 @@ def resolveZeroWidthString(inputstring):
charfound = False charfound = False
binarystring = '' binarystring = ''
resultstring = '' resultstring = ''
inputstring = inputstring.decode('utf-8') #inputstring = inputstring.decode('utf-8')
for char in inputstring: for char in inputstring:
if char == u'\u200b': if char == u'\u200b':
binarystring += '1' binarystring += '1'
@ -204,11 +204,12 @@ def hammingDistance(string1, string2):
return diffs return diffs
def urlEncoder(): def urlEncoder():
input = input('Pleae input your String: ') import urllib.parse
print(urllib.quote_plus(input)) url = input('Pleae input your String: ')
print(urllib.parse.quote(url))
def reverser(): def reverser():
string = input('Please input your string to reverse:') string = input('Please input your string to reverse: ')
print(string[::-1]) print(string[::-1])
def base64prompt(): def base64prompt():
@ -232,7 +233,7 @@ def base64prompt():
if (re.match(b64regex, inputString)): if (re.match(b64regex, inputString)):
print(base64.b64decode(inputString)) print(base64.b64decode(inputString))
else: else:
print(base64.b64encode(inputString)) print(base64.b64encode(inputString.encode()))
def rotPrompt(): def rotPrompt():
@ -283,48 +284,52 @@ def hashPrompt():
inputString = input('Please input a string: ') inputString = input('Please input a string: ')
hasher.update(inputString.encode('utf-8')) hasher.update(inputString.encode('utf-8'))
print(hasher.hexdigest()) print(hasher.hexdigest())
def main():
print('Welcome aboard PankiCrypt Airlines!')
print('How may we serve you today?')
print('1: ROT/Ceasar Encryption')
print('2: Hashing functions')
print('3: Translation')
print('4: Base64 Encoder/Decoder')
print('5: String Reverser')
print('6: URL Encoder')
print('7: Fixed XOR')
print('8: XOR Bruteforce Single Byte ')
print('9: XOR Repeating Key')
print('10: Zero-Width String')
print('11: Resolve Zero-Width Strings')
choice = input('Please make a selection: ')
if (choice == '1'):
rotPrompt()
elif (choice == '2'):
hashPrompt()
elif (choice == '3'):
translatePrompt()
elif(choice == '4'):
base64prompt()
elif(choice == '5'):
reverser()
elif(choice == '6'):
urlEncoder()
elif(choice[0] == '7'):
if(len(choice) > 1):
argList = choice.split(' ')
fixedxor(argList[1], argList[2])
else:
fixedxor()
elif(choice == '8'):
#xorSingleBrute()
xorBrutePrompt()
elif(choice == '9'):
xorRepeating()
elif(choice == '10'):
i = input('String:')
zeroWidthString(i)
elif(choice == '11'):
i = input('String:')
resolveZeroWidthString(i)
print('Thank you for flying with PankiCrypt Airlines!')
print('Welcome aboard PankiCrypt Airlines!')
print('How may we serve you today?') if __name__ == '__main__':
print('1: ROT/Ceasar Encryption') main()
print('2: Hashing functions')
print('3: Translation')
print('4: Base64 Encoder/Decoder')
print('5: String Reverser')
print('6: URL Encoder')
print('7: Fixed XOR')
print('8: XOR Bruteforce Single Byte ')
print('9: XOR Repeating Key')
print('10: Zero-Width String')
print('11: Resolve Zero-Width Strings')
choice = input('Please make a selection: ')
if (choice == '1'):
rotPrompt()
elif (choice == '2'):
hashPrompt()
elif (choice == '3'):
translatePrompt()
elif(choice == '4'):
base64prompt()
elif(choice == '5'):
reverser()
elif(choice == '6'):
urlEncoder()
elif(choice[0] == '7'):
if(len(choice) > 1):
argList = choice.split(' ')
fixedxor(argList[1], argList[2])
else:
fixedxor()
elif(choice == '8'):
#xorSingleBrute()
xorBrutePrompt()
elif(choice == '9'):
xorRepeating()
elif(choice == '10'):
i = input('String:')
zeroWidthString(i)
elif(choice == '11'):
i = input('String:')
resolveZeroWidthString(i)
print('Thank you for flying with PankiCrypt Airlines!')

Loading…
Cancel
Save