Modernize Python 2 code to get ready for Python 3

This commit is contained in:
cclauss
2017-11-25 10:23:50 +01:00
parent a03b2eafc0
commit 4e06949072
95 changed files with 580 additions and 521 deletions

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
import sys, random, cryptomath_module as cryptoMath
SYMBOLS = """ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"""

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
def decrypt(message):
"""
>>> decrypt('TMDETUX PMDVU')

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
# The Caesar Cipher Algorithm
def main():
@@ -12,9 +13,9 @@ def main():
translated = encdec(message, key, mode)
if mode == "encrypt":
print("Encryption:", translated)
print(("Encryption:", translated))
elif mode == "decrypt":
print("Decryption:", translated)
print(("Decryption:", translated))
def encdec(message, key, mode):
message = message.upper()

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
# Primality Testing with the Rabin-Miller Algorithm
import random
@@ -59,5 +60,5 @@ def generateLargePrime(keysize = 1024):
if __name__ == '__main__':
num = generateLargePrime()
print('Prime number:', num)
print('isPrime:', isPrime(num))
print(('Prime number:', num))
print(('isPrime:', isPrime(num)))

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
def dencrypt(s, n):
out = ''
for c in s:

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
import sys, rsa_key_generator as rkg, os
DEFAULT_BLOCK_SIZE = 128

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
import random, sys, os
import rabin_miller as rabinMiller, cryptomath_module as cryptoMath

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
import sys, random
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
import math
def main():

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
import time, os, sys
import transposition_cipher as transCipher
@@ -29,7 +30,7 @@ def main():
outputObj.close()
totalTime = round(time.time() - startTime, 2)
print('Done (', totalTime, 'seconds )')
print(('Done (', totalTime, 'seconds )'))
if __name__ == '__main__':
main()

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def main():