Created
November 12, 2012 14:25
-
-
Save bcho/4059705 to your computer and use it in GitHub Desktop.
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
| #coding: utf-8 | |
| from md5 import md5 | |
| username = '3112005816' | |
| password = '216315' | |
| packet_id = '3' | |
| name = '1' | |
| def to_str(s): | |
| '''convert hex to str''' | |
| ret = [] | |
| for i in range(0, 32, 2): | |
| ret.append(chr(int(s[i:i + 2], 16))) | |
| return ''.join(ret) | |
| def to_hex(s): | |
| '''convert str to hex''' | |
| ret = [] | |
| for i in s: | |
| ret.append(str(hex(ord(i)))[2:4]) | |
| return ''.join(ret) | |
| def challenge(value): | |
| s = '%s%s%s' % (packet_id, password, to_str(value)) | |
| return md5(s).hexdigest() | |
| def main(): | |
| value = open('%s.in' % name, 'r').readlines()[0] | |
| return challenge(value) | |
| if __name__ == '__main__': | |
| exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment