#Variable declaration
#Two prime numbers
p=5;
q=7;
#Calculations
n=p*q;
z=(p-1)*(q-1);
e=5
d=29
#Results
print 'Public keys is (%d, %d)'%(n,e);
print 'Private key is (%d, %d)'%(n,d);
#Variable declaration
p=23; #prime number that both parties agreed upon
g=5;# g is primitive mod p
a=6; #party A choosen number
b=15; #party B choosen number
#Calculations&Results
print 'Party A sends to party B as (g**a mod p) = %d'%(g**a%23);
print 'Party B sends to party A as (g**b mod p) = %d'%(g**b%23);
print 'Party A computes secret key as ((g**b modp)**a mod p) = %d'%(((g**b%23)**a)%p);
print 'Party B computes secret key as ((g**a modp)**b mod p) = %d'%(((g**a%23)**b)%p);