from Crypto.Util.number import * with open('flag.txt','r') as f: m=f.read().encode()…
- User
from Crypto.Util.number import * with open('flag.txt','r') as f: m=f.read().encode() m=bytes_to_long(m) p=getPrime(1024) q=getPrime(1024) N=p*q e=65537 c=pow(m,e,N) print(N) print(p) print(c) #n:27190560459535969368662361436208885061177949970289487773962334199269171630407702896637432435345520427192333106362621158473499069923329717643492010585969793411438273553943526289996932310101118372951771219039518478864491945773285057223218867360299967929774509197540450710254099874429719186926483863456325884119894247061727253141245047965299842829001117193584599887794680434334261157959584345087241051473876321079241967506670515361600451070791034972145179235581254282912581775733209575842615372262084595143807215434257197139568413621890361042745249039787812456507141399573560416210409582569914247494590891186975080437241 #p:153972229960983853454650632327534211732853435443557750739190463348191406891127688593039644701480061775615783852501790919562570214772550461170825707083324053486509179912575660354124342902355293249914935817587919915810309262713616288168825202383821056224729200086998191308492790724149147901872037276837254587121 #c:18295610303051749280984421944313966876905160544874151824299825784219822777282742278665496280050879480275031254401306833476868739070416291035176308662656576171230980515341965427920829900748737911687997553234671809987867432975182363307347515968898798821060680753463847202942993048669178530085495454107868577312777767087108790041450212814200347390046524281954491371047886278727716799730600324655830877100359554789856382595208916511181527643344355267240345414448347645680808624516362886986120368266831887875480846255050985685519252570309317488474990296135020678362076986837144909630175649603806234360986331789609756736030
#Wait,what's the wrong?
- Assistant
There doesn't appear to be anything explicitly wrong with the code. It opens the 'flag.txt' file, reads the contents, and encodes it as bytes. It then generates two large prime numbers,
pandq, and calculates their productN. The variableeis set to 65537, a commonly used value for the public exponent in RSA. Finally, it calculates the ciphertextcby performing modular exponentiation of the messagemusingeas the exponent andNas the modulus.The commented lines at the end provide the values of
N,p, andcfor debugging purposes.If you have any specific concerns or questions about the code, please let me know.