# Alamo City Python Group

Alamo City Python Group Message Board › Python CTF Challenge

# Python CTF Challenge

 Zach Posted 4/20/13 7:18 PM Link to discussion user 89514942 San Antonio, TXPost #: 1 Here is a Python challenge below. Can anybody offer any help to solve this?import random# bleh, figuring out how to decrypt stuff is hard...# good thing there's a service running at wherever the problem description saysciphertext = (191399506312570941099748175129508449452­3614652689932582615239311126533985633211­7664760030665587057736341341088217L, 6981451340216985983024432325647526079415­7685719960610664145090689046057195658068­7935633542046758257396595842622837937744­7329201133443741822196232606915765082265­97259307160898152603847317630021751538L,­ 375)pubkey = 9140361246050720958964986450403171104446­7769368162510130303651530726925696469551­7984683462742136579499746530214988587637­6944965165803509199953554077448911258149­50650516684386468562425056693756001673Ldef numbits(k): if k == 1: return 1 return int(math.ceil(math.log(k,2))) + (1 if k % 2 == 0 else 0)def strtoint(s): if len(s) == 0: return 0 if len(s) == 1: return ord(s[0]) return (ord(s[0]) << (8 * len(s[1:]))) | strtoint(s[1:])def inttostr(s): if s == 0: return "" c = chr(s & 0xFF) return inttostr(s >> 8) + cdef encrypt(m, N): L = numbits(m) random.seed() r = random.randint(2, N-1) x = pow(r, 2, N) y = x l = 0 for k in range(0, L): l = l << 1 l |= y & 1 y = pow(y, 2, N) return (m ^ l, y, L) Doug M. Posted 5/4/13 4:39 PM Link to reply user 27750462 San Antonio, TXPost #: 8 It sucks that this forum trims white space. It's impossible to read this code. :( Zach Posted 5/5/13 5:50 AM Link to reply user 89514942 San Antonio, TXPost #: 2 Yeah I noticed that. This challenge was a little bit harder than I originally thought, I was hoping the hardest part was just interpreting the code, but there was a little more than that. If anybody is interested, there is a write up of the solution at https://blog.inexplic...­ I did learn some python just attempting to understand it though. I am now on Lesson 4 of Code Academy Python.
Powered by mvnForum

### San Antonio, TX

Founded Mar 7, 2013

Help support your Meetup

Contact

#### Our Sponsors

• ##### Geekdom

Space, Pizza and Drinks

#### People in this Meetup are also in:

• ##### CafĂ© Commerce

665 Entrepreneurs

• ##### Ruby Rebels: San Antonio Ruby/Rails Meetup at Geekdom

208 Ruby Rebels

229 Droids

342 Members

• ##### The San Antonio Web Development Group

857 Developers

• ##### San Antonio New Tech

1,239 New Technologists

# Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy