RSA Decrypt (Python Code)
原理部分请看前面的文章: http://www.cnblogs.com/awsqsh/articles/4352286.html
Source file:
Signaure:
RSA public key:
Python Code:
import math
import sys,os
m = 0x1981060b10c969eb18ef30fa661d640b29305788812a7c4258c8e68c5c02260bd10632c81ccaa5aeb21f79219acd5db57e51baa189439c225212168c5f82263a9cf12c03db48b8a4cffa4e31ad4799f1608d7dc35b9f113bbc8ae4bafbc7e78129456bfa6ddb99aba30ca671fb0716c7dd9b4234f4730e01ddb310716848c08e898b7be359409a0c25dffa5e9e909ca3ba900980fe6cb8eaae731040c4662af046f46e86fe7dc85fa09f909c547e0b90a4c6240b91a99de0ca6004e3760b2f043ccc222f4d38634bbc3884393412f1165d680d729a895dea037c4ae7277eaddd2a3770cf011a3959d5cedc2b162e111a37eb5e96f4bd55d6b46981dc712ad643
e = 0x10001
n = 0xaa68da51be6f59d0c179a9d53713315396c373506b8bf21c6c33d9c61a30d3dc39c2cafc7aaca01d2f31733c9bd61ea4d7bc112ee9fd0357646f9249a902331aee95ddeedca7e9dfbd72918469a870c0085e5a959bfa20ea51c6a69a1c57c4ace6f81edebeb77fbfcc5a587eec7377457f76f9e38dbdcea2b11d3b76a0585631464ad458e98a6bcaee4b3027a78ec067ca439dd977208bcf2c3d0f82dbe6f810a3fbb298e28ddeb7b99a4dc9c8b55d71c3f540a05b7902870247675046dcabcb65043b8f50d67ac61e8fa3b9c1d37b3760eecdf01828e5b0d064fd0056b4092127fb2859e0dced382bfb95afd7b3c8774067882f331f158e8d476a338a0aeb19
res = hex(pow(m,e,n))
print res
f = 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff003031300d0609608648016503040201050004207d14ef111230e449c15afa3aeae59e52ee1fa819e33766111b7dbb58bee15f81
d = 0x8db00ece66d3b8cefcff46b994486dfbfd5fd75267897dae2a3d567603b2d384c9b5f006cb8d1ab8095449677c7f250d949eb77ed568dccd5e21f275328434afd0ee651045018c50cef9228b013adf3c9bf8afc2b364ded75555219303bbea3884f68adc53a0c924552a4d6882fb629133715e46d8c497b9e81fd1204a2408cd237d923b123b768195061ca52ccfe8574e9c1b68bdaa85d6bf41e7f8967cdb6b6b91b12188804ff025c9c0561af2d51b06e4023909bda36c5d9f671fd525a5d0ca18e1ccc83efc4cc2814a8b48d252e861eb5c868e3e8d7f05bd0bc359a6fdbfe4f33cc3b415d8ab22f90adf60e3a9f065f4902c7e4d9f70e682a4de7f4db3f1
print hex(pow(f,d,n))
Principia mathematica: a ^ b mod C
Excution:
Below is the hash value:
0x7D, 0x14, 0xEF, 0x11, 0x12, 0x30, 0xE4, 0x49, 0xC1, 0x5A, 0xFA, 0x3A, 0xEA, 0xE5, 0x9E, 0x52,
0xEE, 0x1F, 0xA8, 0x19, 0xE3, 0x37, 0x66, 0x11, 0x1B, 0x7D, 0xBB, 0x58, 0xBE, 0xE1, 0x5F, 0x81,
OK, rsa decrypt success.