Skip to content

Instantly share code, notes, and snippets.

@AndyNovo
Last active April 29, 2016 14:43
Show Gist options
  • Save AndyNovo/af5c57919f86d0424d83f15a369b19ef to your computer and use it in GitHub Desktop.
Save AndyNovo/af5c57919f86d0424d83f15a369b19ef to your computer and use it in GitHub Desktop.
f=file('parameters','r')
lines=f.readlines()
f.close()
params = {}
currentHex=''
currentParam=''
def h2i(hexLines):
if (hexLines == ''):
return 0
return int(hexLines.replace(' ','').replace(':',''), 16)
def splitPoint(hexLines):
gen=hexLines.replace(' ','').replace(':','')[2:]
gl=len(gen)
return (int(gen[:gl/2],16), int(gen[gl/2:], 16))
ecpoints=["Gener", "pub"]
for line in lines:
if line[0].isalpha():
if (currentHex != '' and currentParam != ''):
print "key:",currentParam
if not currentParam in ecpoints:
params[currentParam]=h2i(currentHex)
else:
params[currentParam]=splitPoint(currentHex)
currentParam = line.strip().replace(':','')[:5]
currentHex=''
else:
currentHex+=line.strip()
print params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment