26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
from Crypto.Util.number import inverse, getPrime, bytes_to_long
|
|
|
|
|
|
flag = "h4tum{...}"
|
|
m = bytes_to_long(flag.encode())
|
|
|
|
p = getPrime(512)
|
|
q = getPrime(512)
|
|
n = p * q
|
|
phi = (p - 1) * (q - 1)
|
|
e = 3
|
|
d = inverse(e, phi)
|
|
|
|
|
|
ciphertext = pow(m, e, n)
|
|
|
|
print(f"Here is the public key:\nn = {n}\ne = {e}")
|
|
print(f"\nHere is the encrypted flag:\n{ciphertext}")
|
|
|
|
# Here is the public key:
|
|
# n = 133754776379084890949396128184054209827880534649872344546551916044637014117738848312911601805615413451730371613447269527792021869628568786604565343522407135622719358245312844577182399504053254247235363664243271537669953064325407487226101646170736997104441396305543325547272540155515055362880210828933349672043
|
|
# e = 3
|
|
|
|
# Here is the encrypted flag:
|
|
# 27485520006079233807623807132370137913974673072796110190145166712012781629787795173249446320555776530359265337337323534643030075414274984551090326260078977798035707372748401792308537889036666723735654189543943146031289186076736572201980302715998036022634187371997765033713933871352433152430973165071957865672
|