Permalink
Browse files

upload shit

  • Loading branch information...
Main Main
Main authored and Main committed Oct 12, 2017
1 parent b919205 commit a1e34f4026f727616ff6254882cf65ad5472f192
View
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.6.2 (C:\Users\Myrdd\AppData\Local\Programs\Python\Python36\python.exe)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
View
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6.2 (C:\Users\Myrdd\AppData\Local\Programs\Python\Python36\python.exe)" project-jdk-type="Python SDK" />
</project>
View
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Python.iml" filepath="$PROJECT_DIR$/.idea/Python.iml" />
</modules>
</component>
</project>
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
No changes.
@@ -0,0 +1,167 @@
def rotateEncrypt(phrase, startBits, result):
bits = startBits % len(phrase)
if result == 1 and bits == 0:
print('You\'ve gone full circle.')
firstPart = phrase[bits:]
secondPart = phrase[:bits]
if result == 1:
print('\nThe encrypted phrase is: \'' + firstPart + secondPart + '\'')
startAgain = input('\nWould you like to start over? (Y/N): ')
if startAgain == 'Y':
menu()
elif startAgain == 'y':
menu()
else:
return firstPart + secondPart
def rotateDecrypt(phrase, startBits, result):
bits = startBits % len(phrase)
firstPart = phrase[-bits:]
secondPart = phrase[:-bits]
if result == 1:
print('\nThe original phrase is: \'' + firstPart + secondPart + '\'')
startAgain = input('\nWould you like to start over? (Y/N): ')
if startAgain == 'Y':
menu()
elif startAgain == 'y':
menu()
else:
return firstPart + secondPart
def cypherEncrypt(phrase, startBits, result):
newPhrase = ''
bits = startBits % 26
if result == 1 and bits == 0:
print('You\'ve gone full circle.')
for letter in phrase:
orgLetter = ord(letter)
modLetter = ord(letter) + bits
if 65 <= orgLetter <= 90: #It's uppercase!
if modLetter > 90:
modLetter = modLetter - 26
elif 97 <= orgLetter <= 122: #It's lowercase!
if modLetter > 122:
modLetter = modLetter - 26
else: #PUNCTUATION!!! no touchy.
modLetter = modLetter - bits
newPhrase = newPhrase + chr(modLetter)
if result == 1:
print('\nThe encrypted phrase is: \'' + newPhrase + '\'')
startAgain = input('\nWould you like to start over? (Y/N): ')
if startAgain == 'Y':
menu()
elif startAgain == 'y':
menu()
else:
return newPhrase
def cypherDecrypt(phrase, startBits, result):
newPhrase = ''
bits = startBits % 26
for letter in phrase:
modLetter = ord(letter)
orgLetter = ord(letter) - bits
if 65 <= modLetter <= 90: #It's uppercase!
if orgLetter < 65:
orgLetter = orgLetter + 26
elif 97 <= modLetter <= 122: #It's lowercase!
if orgLetter < 97:
orgLetter = orgLetter + 26
else: #PUNCTUATION!!! no touchy.
orgLetter = orgLetter + bits
newPhrase = newPhrase + chr(orgLetter)
if result == 1:
print('\nThe original phrase is: \'' + newPhrase + '\'')
startAgain = input('\nWould you like to start over? (Y/N): ')
if startAgain == 'Y':
menu()
elif startAgain == 'y':
menu()
else:
return newPhrase
def menu():
print('Your options:\n1: Use Rotational Encryption\n2: Use Alphabetic Cypher\n3: Use Both Methods\n4: Exit')
option = int(input('What would you like to do: '))
if option == 1:
print('1: Encrypt with Rotate\n2: Decrypt with Rotate\n3: Back\n4: Exit')
option = int(input('What would you like to do: '))
if option == 1:
print('\nEncryption using Rotation')
phrase = input('Enter a phrase: ')
bits = int(input('How many bits: '))
rotateEncrypt(phrase, bits, 1)
elif option == 2:
print('\nDecryption using Rotation')
phrase = input('Enter a phrase: ')
bits = int(input('How many bits: '))
rotateDecrypt(phrase, bits, 1)
elif option == 3:
menu()
else:
pass
elif option == 2:
print('1: Encrypt with Cypher\n2: Decrypt with Cypher\n3: Back\n4: Exit')
option = int(input('What would you like to do: '))
if option == 1:
print('\nEncryption using Cypher')
phrase = input('Enter a phrase: ')
bits = int(input('How many bits: '))
cypherEncrypt(phrase, bits, 1)
elif option == 2:
print('\nDecryption using Cypher')
phrase = input('Enter a phrase: ')
bits = int(input('How many bits: '))
cypherDecrypt(phrase, bits, 1)
elif option == 3:
menu()
elif option == 4:
pass
elif option == 3:
print('1: Encrypt with Both Methods\n2: Decrypt with Both Methods\n3: Back\n4: Exit')
option = int(input('What would you like to do: '))
if option == 1:
print('\nEncryption using Both Methods')
phrase = input('Enter a phrase: ')
bits = int(input('How many bits: '))
i = 0
endPhrase = phrase
while i <= bits:
newPhrase = rotateEncrypt(endPhrase, 1, 0) #This doesn't seem to be returning the correct result, probably by the nature of how it increments.
endPhrase = cypherEncrypt(newPhrase, 1, 0) #I just gave it a shot because I was bored.
i = i+1
print(endPhrase)
startAgain = input('\nWould you like to start over? (Y/N): ')
if startAgain == 'Y':
menu()
elif startAgain == 'y':
menu()
elif option == 2:
print('\nDecryption using Both Methods')
phrase = input('Enter a phrase: ')
bits = int(input('How many bits: '))
i = 0
endPhrase = phrase
while i <= bits:
newPhrase = cypherDecrypt(endPhrase, 1, 0)
endPhrase = rotateDecrypt(newPhrase, 1, 0)
i = i+1
print(endPhrase)
startAgain = input('\nWould you like to start over? (Y/N): ')
if startAgain == 'Y':
menu()
elif startAgain == 'y':
menu()
elif option == 3:
menu()
elif option == 4:
pass
elif option == 4:
pass
doOnce = 0
if doOnce == 0:
print('Welcome to the homeworkdrome. Let\'s shuffle some letters round the place.')
menu()
doOnce = 1
View
@@ -0,0 +1,144 @@
def convertTo(block):
fail = 'Not a valid number!'
number = 0
i = 0
x = 1
y = 2
end = len(block)
end = end - 1
while i <= len(block):
numberBit = 0
if i < len(block):
bit = block[-x]
else:
bit = 0
if i < end:
bit2 = block[-y]
else:
bit2 = -1
if bit == 'I':
if bit2 == 'X':
return fail
elif bit2 == 'Y':
return fail
elif bit2 == 'V':
numberBit = 2
else:
numberBit = 1
elif bit == 'K':
if bit2 == 'X':
return fail
elif bit2 == 'Y':
numberBit = 9
elif bit2 == 'V':
numberBit = 6
else:
numberBit = 3
elif bit == 'L':
if bit2 == 'X':
numberBit = 48
elif bit2 == 'Y':
numberBit = 36
elif bit2 == 'V':
numberBit = 24
else:
numberBit = 12
elif bit == 'M':
if bit2 == 'X':
return fail
elif bit2 == 'Y':
numberBit = 180
elif bit2 == 'V':
numberBit = 120
else:
numberBit = 60
elif bit == 'Z':
if bit2 == 'X':
numberBit = 960
elif bit2 == 'Y':
numberBit = 720
elif bit2 == 'V':
numberBit = 480
else:
numberBit = 240
number = number + numberBit
x = x+1
y = y+1
i = i+1
return number
def convertFrom(startNumber):
tooBig = 'Number too large for current methods.'
block = ''
number = startNumber
while number > 0:
if number >= 240:
if number >= 480:
if number >= 720:
if number >= 960:
if number > 1199:
return tooBig
else:
block = 'XZ'
number = number - 960
else:
block = 'YZ'
number = number - 720
else:
block = 'VZ'
number = number - 480
else:
block = 'Z'
number = number - 240
elif number >= 60:
if number >= 120:
if number >= 180:
block = block + 'YM'
number = number - 180
else:
block = block + 'VM'
number = number - 120
else:
block = block + "M"
number = number - 60
elif number >= 12:
if number >= 24:
if number >= 36:
if number >= 48:
block = block + 'XL'
number = number - 48
else:
block = block + 'YL'
number = number - 36
else:
block = block + 'VL'
number = number - 24
else:
block = block + 'L'
number = number - 12
elif number >= 3:
if number >= 6:
if number >= 9:
block = block + 'YK'
number = number - 9
else:
block = block + 'VK'
number = number - 6
else:
block = block + 'K'
number = number - 3
elif number > 1:
block = block + 'VI'
number = number - 2
elif number == 1:
block = block + 'I'
number = number - 1
return block
inp = int(input('Input 1 to convert Block to Number, 2 for Number to Block: '))
if inp == 1:
print(convertTo(input('Enter a block: ')))
input('')
elif inp == 2:
print(convertFrom(int(input('Enter a number: '))))
input('')
Oops, something went wrong.

0 comments on commit a1e34f4

Please sign in to comment.