-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiffie_hellman_project_code.py
93 lines (59 loc) · 2.03 KB
/
diffie_hellman_project_code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# -*- coding: utf-8 -*-
"""Diffie Hellman_Project_code.ipynb
Automatically generated by Colaboratory.
**SECURE COMMUNICATION**
**SECURING COMMUNICATION THROUGH VARIOUS LAYERS**
1st Process..
Implementing Diffie Hellman Exchange Algorithm
"""
# use Python 3 print function
# this code ensures that the print function works the same in Python 2.x and 3.x
from __future__ import print_function
# Variables Used
P = int(input(' Please enter the value of P.'))
print(' Thanks for entering the value of P as ' + str(P))
g = int(input(' Please enter the value of g.'))
print(' Thanks for entering the value of g as ' + str(g))
a = int(input(' \n Please enter the value of a.'))
b = int(input(' Please enter the value of b.'))
# A1 Sends B2 A = g^a mod P
A = (g**a) % P
print( "\n A1 sends over to B2: " , A )
# B2 Sends A1 B = g^b mod P
B = (g ** b) % P
print( " B2 sends over to A1: " , B )
# A1 computes the Shared Secret: S_A1 = B^a mod P
A1SharedSecret = (B ** a) % P
print( " \n A1 Shared Secret: ", A1SharedSecret )
# B2 computes the Shared Secret: S_B2 = A^b mod P
B2SharedSecret = (A**b) % P
print( " B2 Shared Secret: ", B2SharedSecret )
"""2nd PROCESS
Now,
Vignere Process will happen..
Then Polybius Cipher Process...
Easy to Understand !
"""
# Python code to implement
# Vigenere Cipher
# This function generates the
# key in a cyclic manner until
# it's length isn't equal to
# the length of original text
def generateKey(string, key):
key = list(key)
if len(string) == len(key):
return(key)
else:
for i in range(len(string) -
len(key)):
key.append(key[i % len(key)])
return("" . join(key))
"""WAIT WAIT WAIT..... !
There is more Numbers of line of code.
Hi there,
This Project will be Useful for you!
you can use it for your college project.
Also for Startups.
Mail me now at **vatshayan007@gmail.com** to get full explained project code, project report, PPT and research paper on this Project
"""