#This is the given information along with#the encrypted message blocksn=11481322877r=847018765E1=6399300519E2=4085097472E3=3974468445E4=8924762029E5=2887101597E6=3942013007E7=10043617708E8=10379138936E9=3995400497
#Find the factors of nfactor(n)
107033 * 107269
#Discover s using the factors of np=107033q=107269s=inverse_mod(r,(p-1)*(q-1))prints
1394531365
D=list()D.append(power_mod(E1,s,n))D.append(power_mod(E2,s,n))D.append(power_mod(E3,s,n))D.append(power_mod(E4,s,n))D.append(power_mod(E5,s,n))D.append(power_mod(E6,s,n))D.append(power_mod(E7,s,n))D.append(power_mod(E8,s,n))D.append(power_mod(E9,s,n))print"These are the decrypted message blocks:"printD
These are the decrypted message blocks:
[2008050013, 1519200016, 1815120906, 903001301, 2008051301, 2009030901, 1400230119, 5180415, 1900000000]
#This is the key used for decoding the message blockskey={'00':' ','01':'a','02':'b','03':'c','04':'d','05':'e','06':'f','07':'g','08':'h','09':'i','10':'j','11':'k','12':'l','13':'m','14':'n','15':'o','16':'p','17':'q','18':'r','19':'s','20':'t','21':'u','22':'v','23':'w','24':'x','25':'y','26':'z'}
message=""foriinD:i=str(i)j=0k=0#append zeros to the front of the message block#in the case that the block has too few digitsiflen(i)<10:temp=""forjinrange(10-len(i)):temp+="0"i=temp+i#process the message block two digits at a time#and convert each digit pair into a letterwhilek<len(i):message+=key[i[k]+i[k+1]]k+=2print"The secret message is:"printmessage
The secret message is:
the most prolific mathematician was erdos