SlideShare una empresa de Scribd logo
1 de 9
Descargar para leer sin conexión
import random
from random import randrange, getrandbits
from math import log10
from time import time
from functools import reduce
from itertools import repeat
# FRSA
# By: KHAN FARHAN RAFAT
# This code is provided as it is. No implicit and explicit obligations
# Use @ your own RISK
# Credits: Author
# The RSA result (output) is transposed using a key that can be made dynamic :)
# Contacts: ubiquitousorpervasive@gmail.com
def mInverse(p, q):
def xgcd(xP, yP):
#Extended Euclidean Algorithm
seed1, seed0 = 0, 1
t1, t0 = 1, 0
while yP:
q = xP // yP
xP, yP = yP, xP % yP
seed1, seed0 = seed0 - q * seed1, seed1
t1, t0 = t0 - q * t1, t1
return xP, seed0, t0
sP, tP = xgcd(p, q)[0:2]
assert sP == 1
if tP < 0:
tP += q
return tP
def genPrime(nP):
def isPrime(nP, t=7):
def ifComposite(aP):
if pow(aP, dP, nP) == 1:
return False
for i in range(s):
if pow(aP, 2 ** i * dP, nP) == nP - 1:
return False
return True
assert nP > 0
if nP < 3:
return [False, False, True][nP]
elif not nP & 1:
return False
else:
s, dP = 0, nP - 1
while not dP & 1:
s += 1
dP >>= 1
for _ in repeat(None, t):
if ifComposite(randrange(2, n)):
return False
return True
p = getrandbits(n)
while not isPrime(p):
p = getrandbits(n)
return p
# https://crypto.stackexchange.com/questions/3110/impacts-of-not-using-rsa-exponent-of-65537
def genRSA(p, q):
phie, n = (p - 1) * (q - 1), p * q
if n < 65537:
return (3, mInverse(3, phie), n)
else:
return (65537, mInverse(65537, phie), n)
def t2i(text):
return reduce(lambda x, y: (x << 8) + y, map(ord, text))
def i2t(number, size):
text = "".join([chr((number >> j) & 0xff)
for j in reversed(range(0, size << 3, 8))])
return text.lstrip("x00")
def i2l(number, size):
return [(number >> j) & 0xff
for j in reversed(range(0, size << 3, 8))]
def l2i(listInt):
return reduce(lambda x, y: (x << 8) + y, listInt)
def sizeofModulous(mod):
sizeofModulous = len("{:02x}".format(mod)) // 2
return sizeofModulous
def encryptIt(ptext, pk, mod):
size = sizeofModulous(mod)
output = []
while ptext:
nbytes = min(len(ptext), size - 1)
aux1 = t2i(ptext[:nbytes])
assert aux1 < mod
aux2 = pow(aux1, pk, mod)
output += i2l(aux2, size + 2)
ptext = ptext[size:]
return output
def decryptIt(ctext, sk, p, q):
mod = p * q
size = sizeofModulous(mod)
output = ""
while ctext:
auxP = l2i(ctext[:size + 2])
assert auxP < mod
m1 = pow(auxP, sk % (p - 1), p)
m2 = pow(auxP, sk % (q - 1), q)
hP = (mInverse(q, p) * (m1 - m2)) % p
aux4 = m2 + hP * q
output += i2t(aux4, size)
ctext = ctext[size + 2:]
return output
def transP(matrix, words):
cipher = ''
length = len(matrix)
blanks = ''.join(' ' for i in range(length - 1))
for x in range(0, len(words), length):
# todo optimization
item = words[x: x + length] + blanks
for pos in matrix:
cipher += item[pos - 1]
return cipher
def rotaTe(matrix):
length = len(matrix)
arr = [0] * length
for i in range(length):
arr[matrix[i] - 1] = i + 1
return arr
def printHexList(intList):
for index, elem in enumerate(intList):
if index % 32 == 0:
print()
print("{:02x}".format(elem), end="")
print()
def printLargeInteger(number):
string = "{:02x}".format(number)
for jP in range(len(string)):
if jP % 64 == 0:
print()
print(string[jP], end="")
print()
def useCase(p, q, msg):
#print("Computed Key size is : {:0d} bits".format(round(log10(p * q) / log10(2))))
pk, sk, mod = genRSA(p, q)
print("nPhi ",end="")
printLargeInteger(mod)
print("nNow Encrypting ... ... ...")
st = time()
cText = reduce(lambda string, item: string + chr(item), encryptIt(msg, pk, mod), "")
print("nCiphertext: ")
print(cText)
matrix = [6, 2, 4, 1, 7, 3, 8, 5]
ciphertext = transP(matrix, cText)
print("nTransposed String:n", end="")
print(ciphertext)
en = time()
print("Encryption took ", end="")
print("({:0.3f}) seconds".format(round(en - st, 3)))
print("-------------------------------")
print("nNow Decrypting ... ... ...")
st = time()
secret = rotaTe(matrix)
cText=transP(secret, ciphertext).strip()
print("nReversed Transposition n", cText)
k = []
for c in cText:
k.append(ord(c))
cText = k
pText = decryptIt(cText, sk, p, q)
en = time()
print("nDecrypted Text:", pText)
print("nDecryption took ", end="")
print("({:0.3f}) seconds".format(round(en - st, 3)))
print("-------------------------------")
if __name__ == "__main__":
Message=input("Type in your Message! : ")
n=int(input("Enter Length (in bits) for generating Primes p and q ! (256, 512, 1024, 2048) : "))
st = time()
p = genPrime(n)
q = genPrime(n)
en = time()
print("nPrime (p): ", end="")
printLargeInteger(p)
print("nPrime (q): ", end="")
printLargeInteger(q)
print("nTime elapsed in generating {:0d}-bit prime = ".format(n), end="")
print("({:0.3f}) seconds".format(round(en - st, 3)))
print("----------------------------------------------------------")
useCase(p, q, Message)

Más contenido relacionado

La actualidad más candente

ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
hayato
 

La actualidad más candente (20)

Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++
 
C++ TUTORIAL 7
C++ TUTORIAL 7C++ TUTORIAL 7
C++ TUTORIAL 7
 
Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoF
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPU
 
Short intro to the Rust language
Short intro to the Rust languageShort intro to the Rust language
Short intro to the Rust language
 
Python For Data Science Cheat Sheet
Python For Data Science Cheat SheetPython For Data Science Cheat Sheet
Python For Data Science Cheat Sheet
 
Cquestions
Cquestions Cquestions
Cquestions
 
The simplest existential graph system
The simplest existential graph systemThe simplest existential graph system
The simplest existential graph system
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
 
Py3k
Py3kPy3k
Py3k
 
20170714 concurrency in julia
20170714 concurrency in julia20170714 concurrency in julia
20170714 concurrency in julia
 
関数プログラミングことはじめ revival
関数プログラミングことはじめ revival関数プログラミングことはじめ revival
関数プログラミングことはじめ revival
 
Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheet
 
Coding
CodingCoding
Coding
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
2 a networkflow
2 a networkflow2 a networkflow
2 a networkflow
 
ゼロから始めるScala文法
ゼロから始めるScala文法ゼロから始めるScala文法
ゼロから始めるScala文法
 
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : NotesCUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
 
Python Cheat Sheet
Python Cheat SheetPython Cheat Sheet
Python Cheat Sheet
 

Similar a Frsa

Similar a Frsa (20)

Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
Array
ArrayArray
Array
 
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
 
Nbvtalkatbzaonencryptionpuzzles
NbvtalkatbzaonencryptionpuzzlesNbvtalkatbzaonencryptionpuzzles
Nbvtalkatbzaonencryptionpuzzles
 
Nbvtalkatbzaonencryptionpuzzles
NbvtalkatbzaonencryptionpuzzlesNbvtalkatbzaonencryptionpuzzles
Nbvtalkatbzaonencryptionpuzzles
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
User Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love StoryUser Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love Story
 
User Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love StoryUser Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love Story
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
 
R Language Introduction
R Language IntroductionR Language Introduction
R Language Introduction
 
Gentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingGentle Introduction to Functional Programming
Gentle Introduction to Functional Programming
 
Python basic
Python basic Python basic
Python basic
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Programs in array using SWIFT
Programs in array using SWIFTPrograms in array using SWIFT
Programs in array using SWIFT
 
PRACTICAL COMPUTING
PRACTICAL COMPUTINGPRACTICAL COMPUTING
PRACTICAL COMPUTING
 
Recursion in C
Recursion in CRecursion in C
Recursion in C
 

Último

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Último (20)

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 

Frsa

  • 1. import random from random import randrange, getrandbits from math import log10 from time import time from functools import reduce from itertools import repeat # FRSA # By: KHAN FARHAN RAFAT # This code is provided as it is. No implicit and explicit obligations # Use @ your own RISK # Credits: Author # The RSA result (output) is transposed using a key that can be made dynamic :) # Contacts: ubiquitousorpervasive@gmail.com def mInverse(p, q): def xgcd(xP, yP): #Extended Euclidean Algorithm seed1, seed0 = 0, 1 t1, t0 = 1, 0 while yP: q = xP // yP xP, yP = yP, xP % yP seed1, seed0 = seed0 - q * seed1, seed1 t1, t0 = t0 - q * t1, t1 return xP, seed0, t0 sP, tP = xgcd(p, q)[0:2] assert sP == 1
  • 2. if tP < 0: tP += q return tP def genPrime(nP): def isPrime(nP, t=7): def ifComposite(aP): if pow(aP, dP, nP) == 1: return False for i in range(s): if pow(aP, 2 ** i * dP, nP) == nP - 1: return False return True assert nP > 0 if nP < 3: return [False, False, True][nP] elif not nP & 1: return False else: s, dP = 0, nP - 1 while not dP & 1: s += 1 dP >>= 1 for _ in repeat(None, t): if ifComposite(randrange(2, n)):
  • 3. return False return True p = getrandbits(n) while not isPrime(p): p = getrandbits(n) return p # https://crypto.stackexchange.com/questions/3110/impacts-of-not-using-rsa-exponent-of-65537 def genRSA(p, q): phie, n = (p - 1) * (q - 1), p * q if n < 65537: return (3, mInverse(3, phie), n) else: return (65537, mInverse(65537, phie), n) def t2i(text): return reduce(lambda x, y: (x << 8) + y, map(ord, text)) def i2t(number, size): text = "".join([chr((number >> j) & 0xff) for j in reversed(range(0, size << 3, 8))]) return text.lstrip("x00")
  • 4. def i2l(number, size): return [(number >> j) & 0xff for j in reversed(range(0, size << 3, 8))] def l2i(listInt): return reduce(lambda x, y: (x << 8) + y, listInt) def sizeofModulous(mod): sizeofModulous = len("{:02x}".format(mod)) // 2 return sizeofModulous def encryptIt(ptext, pk, mod): size = sizeofModulous(mod) output = [] while ptext: nbytes = min(len(ptext), size - 1) aux1 = t2i(ptext[:nbytes]) assert aux1 < mod aux2 = pow(aux1, pk, mod) output += i2l(aux2, size + 2)
  • 5. ptext = ptext[size:] return output def decryptIt(ctext, sk, p, q): mod = p * q size = sizeofModulous(mod) output = "" while ctext: auxP = l2i(ctext[:size + 2]) assert auxP < mod m1 = pow(auxP, sk % (p - 1), p) m2 = pow(auxP, sk % (q - 1), q) hP = (mInverse(q, p) * (m1 - m2)) % p aux4 = m2 + hP * q output += i2t(aux4, size) ctext = ctext[size + 2:] return output def transP(matrix, words): cipher = '' length = len(matrix) blanks = ''.join(' ' for i in range(length - 1)) for x in range(0, len(words), length): # todo optimization item = words[x: x + length] + blanks
  • 6. for pos in matrix: cipher += item[pos - 1] return cipher def rotaTe(matrix): length = len(matrix) arr = [0] * length for i in range(length): arr[matrix[i] - 1] = i + 1 return arr def printHexList(intList): for index, elem in enumerate(intList): if index % 32 == 0: print() print("{:02x}".format(elem), end="") print() def printLargeInteger(number): string = "{:02x}".format(number) for jP in range(len(string)): if jP % 64 == 0: print() print(string[jP], end="")
  • 7. print() def useCase(p, q, msg): #print("Computed Key size is : {:0d} bits".format(round(log10(p * q) / log10(2)))) pk, sk, mod = genRSA(p, q) print("nPhi ",end="") printLargeInteger(mod) print("nNow Encrypting ... ... ...") st = time() cText = reduce(lambda string, item: string + chr(item), encryptIt(msg, pk, mod), "") print("nCiphertext: ") print(cText) matrix = [6, 2, 4, 1, 7, 3, 8, 5] ciphertext = transP(matrix, cText) print("nTransposed String:n", end="") print(ciphertext) en = time() print("Encryption took ", end="") print("({:0.3f}) seconds".format(round(en - st, 3))) print("-------------------------------") print("nNow Decrypting ... ... ...") st = time() secret = rotaTe(matrix)
  • 8. cText=transP(secret, ciphertext).strip() print("nReversed Transposition n", cText) k = [] for c in cText: k.append(ord(c)) cText = k pText = decryptIt(cText, sk, p, q) en = time() print("nDecrypted Text:", pText) print("nDecryption took ", end="") print("({:0.3f}) seconds".format(round(en - st, 3))) print("-------------------------------") if __name__ == "__main__": Message=input("Type in your Message! : ") n=int(input("Enter Length (in bits) for generating Primes p and q ! (256, 512, 1024, 2048) : ")) st = time() p = genPrime(n) q = genPrime(n) en = time() print("nPrime (p): ", end="") printLargeInteger(p) print("nPrime (q): ", end="") printLargeInteger(q)
  • 9. print("nTime elapsed in generating {:0d}-bit prime = ".format(n), end="") print("({:0.3f}) seconds".format(round(en - st, 3))) print("----------------------------------------------------------") useCase(p, q, Message)