0% found this document useful (0 votes)
26 views2 pages

ICS-Assignment 3 Code & Output

Uploaded by

Mansi Dhake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

ICS-Assignment 3 Code & Output

Uploaded by

Mansi Dhake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Nikita Marne

24276

72004863L

ICS

ASSIGNMENT 3 CODE:
#Diffie Hellman Key Exchange Alogorithm
# Begin sharedPrime = int(input("Enter shared
Prime(n):")) sharedBase = int(input("Enter shared
Base(g):")) aliceSecret = int(input("Enter Alice
Secret Key(x):")) bobSecret = int(input("Enter Bob
Secret Key(y):")) print( "\nPublicly Shared
Variables:") print( "Publicly Shared Prime: " ,
sharedPrime ) print( "Publicly Shared Base: " ,
sharedBase )

# Alice Sends Bob A = g^x mod n


A = (sharedBase**aliceSecret) % sharedPrime
print( "\nAlice Sends(A) Over Public Chanel: " , A )

# Bob Sends Alice B = g^y mod n


B = (sharedBase ** bobSecret) % sharedPrime
print("Bob Sends(B) Over Public Chanel: ", B )
print( "\n------------\n" ) print( "Privately
Calculated Shared Secret:" ) # Alice Computes Shared
Secret: K1 = B^x mod n aliceSharedSecret = (B **
aliceSecret) % sharedPrime print( "Alice Shared
Secret: ", aliceSharedSecret )

# Bob Computes Shared Secret: K2 = A^y mod n


bobSharedSecret = (A**bobSecret) % sharedPrime print(
"9Bob Shared Secret: ", bobSharedSecret )

OUTPUT:

You might also like