Skip to content

Commit c55adda

Browse files
author
codehouseindia
authored
Merge pull request codehouseindia#535 from Sakshi725744/revert-398-patch-2
Added Diffie Hellman Algorithm Python code
2 parents f3b2acc + 7f73859 commit c55adda

2 files changed

Lines changed: 34 additions & 12 deletions

Diffie Hellman Algorithm.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#The Diffie-Hellman algorithm is being used to establish a shared secret
2+
#that can be used for secret communications while exchanging data over a
3+
#public network using the elliptic curve to generate points and get the secret key using the parameters
4+
if __name__ == '__main__':
5+
#Public Keys P and G
6+
P = int(input("Enter Public Key P: "))
7+
8+
9+
G = int(input("Enter Public Key G: "))
10+
11+
12+
# Alice will choose the private key a
13+
a = int(input("Enter Private Key for Alice: "))
14+
15+
# Bob will choose the private key b
16+
b = int(input("Enter Private Key for Bob: "))
17+
18+
# gets the generated key
19+
ga = int((G**a)%P)
20+
21+
22+
# gets the generated key
23+
gb = int((G**b)%P)
24+
25+
print("Exchanging Generated Keys")
26+
27+
# Secret key for Alice
28+
ka = int((gb**a)%P)
29+
30+
# Secret key for Bob
31+
kb = int((ga**b)%P)
32+
33+
print('Secret key for the Alice is : %d'%(ka))
34+
print('Secret Key for the Bob is : %d'%(kb))

Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string. Go to the editor Sample String : 'The lyrics is not that poor!' 'The lyrics is poor!' Expected Result : 'The lyrics is good!' 'The lyrics is poor!'

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)