Question

In: Computer Science

import tkinter as tk import math window = tk.Tk() window.title("RSA Encryption/Decryption") window.geometry("500x500") #screen.configure(background="black") #functions def Modulus():...

import tkinter as tk
import math

window = tk.Tk()
window.title("RSA Encryption/Decryption")
window.geometry("500x500")
#screen.configure(background="black")

#functions
def Modulus():
p = int(p_input1.get())
q = int(q_input1.get())
n = p*q

  
open_text = tk.Label(text="Keep your Messages Secure", fg = "white", bg = "blue")
open_text.pack()


Encryp_text = tk.Label(text="Encryption", fg="white", bg="red")
Encryp_text.place(x=200, y=35)

Decryp_text = tk.Label(text="Decryption", fg="white", bg="green")
Decryp_text.place(x=200, y=270)

p_input=tk.Label(text="Enter the value of P: ")
p_input.place(x=10, y=58)

p_input1=tk.Entry()
p_input1.place(x = 130, y=58)

q_input=tk.Label(text="Enter the value of q:")
q_input.place(x=10, y=78)

q_input1=tk.Entry()
q_input1.place(x = 130, y=78)


mod = tk.Label(text= "RSA Modulus(n)is: ",command = Modulus)
mod.place(x=10, y=100)

window.mainloop()

i'm not able to get the result which is the value of n. can you please help with this?

Solutions

Expert Solution

For this program, the control with the name mod should not be a label, it should be a button which must be created as

mod = tk.Button(text= "RSA Modulus(n)is: ",command = Modulus)

The button control has command argument

To display the result, i.e value of n, a label is created inside the Modulus function to which value of n is assigned after converting n to string.

mod_output=tk.Label(text=str(n))
mod_output.place(x=135, y=100)

The complete program and out put screen is given for your reference.

import tkinter as tk
import math

window = tk.Tk()
window.title("RSA Encryption/Decryption")
window.geometry("500x500")
#screen.configure(background="black")

#functions
def Modulus():
p = int(p_input1.get())
q = int(q_input1.get())
n = p*q
mod_output=tk.Label(text=str(n))
mod_output.place(x=135, y=100)

  
open_text = tk.Label(text="Keep your Messages Secure", fg = "white", bg = "blue")
open_text.pack()


Encryp_text = tk.Label(text="Encryption", fg="white", bg="red")
Encryp_text.place(x=200, y=35)

Decryp_text = tk.Label(text="Decryption", fg="white", bg="green")
Decryp_text.place(x=200, y=270)

p_input=tk.Label(text="Enter the value of P: ")
p_input.place(x=10, y=58)

p_input1=tk.Entry()
p_input1.place(x = 130, y=58)

q_input=tk.Label(text="Enter the value of q:")
q_input.place(x=10, y=78)

q_input1=tk.Entry()
q_input1.place(x = 130, y=78)


mod = tk.Button(text= "RSA Modulus(n)is: ",command = Modulus)
mod.place(x=10, y=100)


window.mainloop()

PROGRAM

import tkinter as tk
import math

window = tk.Tk()
window.title("RSA Encryption/Decryption")
window.geometry("500x500")
#screen.configure(background="black")

#functions
def Modulus():
  p = int(p_input1.get())
  q = int(q_input1.get())
  n = p*q
  mod_output=tk.Label(text=str(n))
  mod_output.place(x=135, y=100)

  
open_text = tk.Label(text="Keep your Messages Secure", fg = "white", bg = "blue")
open_text.pack()


Encryp_text = tk.Label(text="Encryption", fg="white", bg="red")
Encryp_text.place(x=200, y=35)

Decryp_text = tk.Label(text="Decryption", fg="white", bg="green")
Decryp_text.place(x=200, y=270)

p_input=tk.Label(text="Enter the value of P: ")
p_input.place(x=10, y=58)

p_input1=tk.Entry()
p_input1.place(x = 130, y=58)

q_input=tk.Label(text="Enter the value of q:")
q_input.place(x=10, y=78)

q_input1=tk.Entry()
q_input1.place(x = 130, y=78)


mod = tk.Button(text= "RSA Modulus(n)is: ",command = Modulus)
mod.place(x=10, y=100)


window.mainloop()

OUTPUT SCREEN


Related Solutions

import math print("RSA ENCRYPTION/DECRYPTION") print("*****************************************************") #Input Prime Numbers print("PLEASE ENTER THE 'p' AND 'q' VALUES BELOW:")...
import math print("RSA ENCRYPTION/DECRYPTION") print("*****************************************************") #Input Prime Numbers print("PLEASE ENTER THE 'p' AND 'q' VALUES BELOW:") p = int(input("Enter a prime number for p: ")) q = int(input("Enter a prime number for q: ")) print("*****************************************************") #Check if Input's are Prime '''THIS FUNCTION AND THE CODE IMMEDIATELY BELOW THE FUNCTION CHECKS WHETHER THE INPUTS ARE PRIME OR NOT.''' def prime_check(a): if(a==2): return True elif((a<2) or ((a%2)==0)): return False elif(a>2): for i in range(2,a): if not(a%i): return false return True check_p =...
Alice is sending message “HIDE” to Bob. Perform encryption and decryption using RSA algorithm, with the...
Alice is sending message “HIDE” to Bob. Perform encryption and decryption using RSA algorithm, with the following information: parameters p=11,q=5, e=7 Present all the information that you will need to encrypt and decrypt only the first letter from text
Python 3 Fix the code and rovide the correct indentation Code: import tkinter as tk from...
Python 3 Fix the code and rovide the correct indentation Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product = tk.Entry(window) money =...
Given two prime numbers 17 and 19. Compute the encryption and the decryption keys using RSA...
Given two prime numbers 17 and 19. Compute the encryption and the decryption keys using RSA algorithm.
Python 3 Calendar does not showing up Fix code: # required library import tkinter as tk...
Python 3 Calendar does not showing up Fix code: # required library import tkinter as tk from tkcalendar import DateEntry import xlsxwriter # frame window = tk.Tk() window.title("daily logs") #window.resizable(0,0) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=3, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product = tk.Entry(window) money = tk.Entry(window) # arraging barcode.grid(row=0, column=1) product.grid(row=1, column=1) money.grid(row=2, column=1) cal = DateEntry(window, width=12, year=2019,...
Please perform encryption and decryption given the following values of an RSA public key cryptosystem; p=17,...
Please perform encryption and decryption given the following values of an RSA public key cryptosystem; p=17, q=31, e=7 and M=2
Please fix all the errors in this Python program. import math def solve(a, b, c): """...
Please fix all the errors in this Python program. import math def solve(a, b, c): """ Calculate solution to quadratic equation and return @param coefficients a,b,class @return either 2 roots, 1 root, or None """ #@TODO - Fix this code to handle special cases d = b ** 2 - 4 * a * c disc = math.sqrt(d) root1 = (-b + disc) / (2 * a) root2 = (-b - disc) / (2 * a) return root1, root2 if...
import random # define functions def rollDice(): # function returns a random number between 1 and...
import random # define functions def rollDice(): # function returns a random number between 1 and 6 def userWon(t1, t2): # function accepts player total and computer total # function returns true if player wins # function returns false if computer wins def main(): # each player rolls two Dice player = rollDice() + rollDice() computer = rollDice() + rollDice() # ask the player if they want to roll again again = int(input("Please enter 1 to roll again. Enter 2...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT