Created
July 14, 2013 01:47
-
-
Save rikaardhosein/5992879 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/python | |
import sys | |
import base64 | |
import struct | |
filename = sys.argv[1] | |
file_contents = open(filename,'rb').read() | |
base64_encoded_info = file_contents.split(' ')[1] | |
raw_bytes = base64.b64decode(base64_encoded_info) | |
length = struct.unpack('>I',raw_bytes[0:4])[0] | |
raw_bytes = raw_bytes[4:] | |
data = raw_bytes[0:length] | |
print 'Obtained string: %s'%(data) | |
raw_bytes = raw_bytes[length:] | |
exponent_size = struct.unpack('>I',raw_bytes[0:4])[0] | |
print 'Exponent size: %d'%(exponent_size) | |
raw_bytes = raw_bytes[4:] | |
exponent = 0 | |
for i in range(0,exponent_size): | |
exponent<<=8 | |
exponent += ord(raw_bytes[i]) | |
print 'Exponent: '+str(exponent) | |
raw_bytes = raw_bytes[exponent_size:] | |
modulus_size = struct.unpack('>I',raw_bytes[0:4])[0] | |
raw_bytes = raw_bytes[4:] | |
print 'Modulus size: %d'%(modulus_size) | |
modulus = 0 | |
for i in range(0,modulus_size): | |
modulus<<=8 | |
modulus += ord(raw_bytes[i]) | |
print 'Modulus: '+str(modulus) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment