Created
November 8, 2017 10:31
-
-
Save minhtt159/1b978cbe6afa560488d6ac983077ded8 to your computer and use it in GitHub Desktop.
SvATTT2017 - Crypto 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a309cf189cdee501959940feba153461eef5201e00639caac3bbdf4c2f8295703975dd2786c6b8a1ad03ae204ac0693e5886dca64f1d717b6840985f10caca728f5725e60fa7b69f1f968d447b2d6199ae3ce0be378cc33155a2d94c8c22438 2ec106245f4b07a2a99f6949750ff48e97cbe8434ec0038e0e2bcce7cc7d9f0305a5a5358637e5d31158fecf2ab6306be80e9eabc219673d974db197ccbf97afec3d27165ff7a5d3af573d6e973b6c8f124e50f8bf2e111595c07560f40097b4 5f0f2fbe27cff7785ecb9e834b9201c086ab6a2a211e3a2807bce8db68bf452369e5610f463225f41a9f254f46ee6816f53d7e6496a84eab08fded7f9bba2aadad25cf6e9b95c6a5a4f355d9b580ba496fa824fcc1a082f364625b1a871117ba 6844981dbfd05b1912e7f20adcb108d2ad134ed313bc3d24cc18a0a41525b258ab0412d928a7a9529299154d62d1e92822f1081e645512f609d9bed0f8c2f2de56f1fb0cbfe49e7dffd4989d08fd07f627b7bb4c4388b632d0ff327adcf2cd2d 2ecc34bccbb70ace772e9563eeb01fb50e8321e672dacaf1e79376882e7a6ea3c9088504f35922ea3d3f571b5cac64f9dd6c2dd66c27fb02295b97e0013425c9fd898ac609d4941e99dc51fc6a5e3c11dffcdeb905d64bcfc97915e1fab69cf0 76edfba1dacef5a8a95fceb46be785a4f6c31eda3f2aef3bb63d2107c547962ab0dd32490589bd93a5661620319becd11714a1cde3060d229f6e42a56ca961f611ba868606141d627e2451f75ac090cf066187c9660f040211f6ef16cdb6197d afad9c5327b0646c04918e02b4e7c0a09007850af04914c382e6eb5ddbe4ce0f959a581f28802d5e68462362d527fe8dce858a7ca80f825413d73f2ade27e0b21e3b016bfac30a749c0bc208cf960f6f00c8a3f0a9fc0164cbbfdf74da7cc147 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gmpy2 | |
from ctf import MESSAGES | |
N = 1552518092300708935148979488462502555256886017116696611139052038026050952686376886330878408828646477971459063658923221258297866648143023058142446317581796810373905913084934869211153276980011573717416472395713363686571638755823503877 | |
e = 3 | |
BS = 32 | |
to_int = lambda text: int(''.join(x.encode('hex') for x in text), 16) | |
c = 0L | |
cipher = [] | |
for chunk in [MESSAGES[i:i + BS] for i in range(0, len(MESSAGES), BS)]: | |
c1 = int(hex(c)[2:-1][:BS*2+1], 16) | |
c = gmpy2.powmod(c1 + to_int(chunk), e, N) | |
cipher.append(hex(c)[2:]) | |
with open('cipher.txt', 'w') as f: | |
f.write(' '.join(cipher)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment