Skip to content

Instantly share code, notes, and snippets.

@Habbie
Created October 16, 2017 12:05
Show Gist options
  • Save Habbie/23ef81ac9c4fed95720fe1970adddf23 to your computer and use it in GitHub Desktop.
Save Habbie/23ef81ac9c4fed95720fe1970adddf23 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
for line in sys.stdin:
parts = line.split()
if int(parts[6]) in (1, 5, 7, 8, 10):
pubkeys = ''.join(parts[7:]).replace(' ', '')
pubkey = pubkeys.decode('base64')
expoffset = 1
explen = ord(pubkey[0])
if not explen:
explen = ord(pubkey[1]) * 256 + ord(pubkey[2])
expoffset = 4
exponent = pubkey[expoffset:expoffset+explen]
modulus = pubkey[expoffset+explen:]
#print("exponent:", exponent.encode('base64'))
#print("modulus:", modulus.encode('base64'))
print modulus.encode('base64').replace('\n', ''), pubkeys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment