Professional Documents
Culture Documents
Given:
-p (prime) = 43
-q (prime)= 47
For doing this we use the function Modinv to nd the mod inverse of ‘e’, which is
basically equal to ‘d’.
here in the code we use b string as we want the literals representing the integers to be
between 0 and 255, along with the digital signature and bob reviews whether h is equal to
h(m) produced or not and prints out the validity of the signature if needed. Here we
named the values h(m),h as hashm and hash and checked the validity(correct or
unaltered), and to print the digest of the message we used Messagesent.digest()
command and printed out the digest of the hash value h(m).
1.
e = 155
p = 43
q = 47
n = p*q
def Eulersphi(t):
return (p-1)*(q-1)
key1 = n,e
def Modinv(k,h):
for i in range(h):
if (k*i)%h==1:
return i
d = Modinv(e,Eulersphi(n))
key2 = n,d
2.
M = RSA.generate(bits = 1024)
n = (M.n)
d = (M.d)
e = (M.e)
import hashlib
fi
fi
Messagesent = hashlib.sha512()
Messagesent.digest()
Out 1.
Out 2.
Message signature s is :
597104975514875451599482553370672525879060980711796678717221629108740509
740709647249634642216017969309237282199028025871307570832163659265399640
077347954520853487101328830671086309758490193109614501622940403069236156
617444103422871456281508789625755477040134827735468832252491466550789326
94478354885881394301