mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
Modernize Python 2 code to get ready for Python 3
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import sys, random, cryptomath_module as cryptoMath
|
||||
|
||||
SYMBOLS = """ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"""
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
def decrypt(message):
|
||||
"""
|
||||
>>> decrypt('TMDETUX PMDVU')
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)))
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
def dencrypt(s, n):
|
||||
out = ''
|
||||
for c in s:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import sys, rsa_key_generator as rkg, os
|
||||
|
||||
DEFAULT_BLOCK_SIZE = 128
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import random, sys, os
|
||||
import rabin_miller as rabinMiller, cryptomath_module as cryptoMath
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import sys, random
|
||||
|
||||
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import math
|
||||
|
||||
def main():
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user