-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathRSA_deCrypt.py
21 lines (21 loc) · 1014 Bytes
/
RSA_deCrypt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from decimal import *
e = 3
c = 24169313728564942442211774792718133649505303766122840641824238947925887523809659286479788261358160947897827563877730687191196979635981766007541262794064747436339518434662376001187909548541032912960261470378632234919864504416430112988325282635602076675727609986764939035311005911495050936123288502045541159782290557092166459385730265169804173086982862520503253166994397834568988061050489364671603850794860660038045636906752404250094067941258320535890143754097216
i = 100
while i < 2000:
getcontext().prec = i
cube_root = int(
(Decimal(c) ** (Decimal(1) / Decimal(3))).to_integral_exact())
hex_str = hex(cube_root)[2:]
try:
dehex = bytes.fromhex(hex_str).decode()
flag = bytes.fromhex(dehex).decode()
if flag.startswith('twc{') and flag.endswith('}'):
print('Precision :', i)
print('FLAG :', flag)
break
except UnicodeDecodeError:
pass
except ValueError:
pass
i += 1