Skip to content

Instantly share code, notes, and snippets.

@taxilian
Created April 8, 2015 21:27
Show Gist options
  • Save taxilian/d42b8768b2e3ef5c6998 to your computer and use it in GitHub Desktop.
Save taxilian/d42b8768b2e3ef5c6998 to your computer and use it in GitHub Desktop.
Python script to generate a chrome extension key and the matching id
import hashlib
import os
from Crypto.PublicKey import RSA
KEYSIZE = 1024
# Generate an RSA key
rsakey = RSA.generate(KEYSIZE, os.urandom)
# grab the public key portion
publickey = rsakey.publickey()
digest = hashlib.sha256(publickey.exportKey('DER')).hexdigest()[:32]
extension_id = ''.join(["abcdefghijklmnop"[int(i,16)] for i in digest])
print ''.join(publickey.exportKey().split('\n')[1:-1])
print extension_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment