A good and easy way to get the public key from a .crx file using python, since chrome only generates the .pem private key for you. The public key is actually stored in the .crx file.
This is based on the .crx file format found here http://developer.chrome.com/extensions/crx.html
import struct import hashlib import string def get_pub_key_from_crx(crx_file): with open(crx_file, 'rb') as f: data = f.read() header = struct.unpack('<4sIII', data[:16]) pubkey = struct.unpack('<%ds' % header[2], data[16:16+header[2]])[0] return pubkey def get_extension_id(crx_file): pubkey = get_pub_key_from_crx(crx_file) digest = hashlib.sha256(pubkey).hexdigest() trans = string.maketrans('0123456789abcdef', string.ascii_lowercase[:16]) return string.translate(digest[:32], trans) if __name__ == '__main__': import sys if len(sys.argv) != 2: print 'usage: %s crx_file' % sys.argv[0] print get_extension_id(sys.argv[1])
Although this cannot be done "bypassing the interaction with the browser", because you still need to generate the .crx file with a command like
chrome.exe --pack-extension=my_extension --pack-extension-key=my_extension.pem
source share