Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168745
Image: ubuntu2004
#This is the given information along with #the encrypted message blocks n = 11481322877 r = 847018765 E1 = 6399300519 E2 = 4085097472 E3 = 3974468445 E4 = 8924762029 E5 = 2887101597 E6 = 3942013007 E7 = 10043617708 E8 = 10379138936 E9 = 3995400497
#Find the factors of n factor(n)
107033 * 107269
#Discover s using the factors of n p = 107033 q = 107269 s = inverse_mod(r, (p-1) * (q-1)) print s
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:" print D
These are the decrypted message blocks: [2008050013, 1519200016, 1815120906, 903001301, 2008051301, 2009030901, 1400230119, 5180415, 1900000000]
#This is the key used for decoding the message blocks key = {'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 = "" for i in D: i = str(i) j = 0 k = 0 #append zeros to the front of the message block #in the case that the block has too few digits if len(i) < 10: temp = "" for j in range(10 - len(i)): temp += "0" i = temp + i #process the message block two digits at a time #and convert each digit pair into a letter while k < len(i): message += key[i[k] + i[k + 1]] k += 2 print "The secret message is:" print message
The secret message is: the most prolific mathematician was erdos