今天我在为Chrome创建一个新的主题创建器时遇到了一个问题。如您所知,Chrome使用称为CRX的“新”文件格式来管理其插件和主题。这是一个基本的zip文件,但有点修改:如何用C#代码替换openSSL调用?
“CR24” + derkey +签名+压缩文件
这里来的问题。只有两个用Ruby或Python编写的CRX创建器。我不太了解这两种语言(尽管在Python中有一些基本的经验,但主要是使用PyS60),所以我想请你帮助我将这个Python应用程序转换为不依赖于外部程序的C#代码。
而且,这里是crxmake.py来源:
#!/usr/bin/python
# Cribbed from http://github.com/Constellation/crxmake/blob/master/lib/crxmake.rb
# and http://src.chromium.org/viewvc/chrome/trunk/src/chrome/tools/extensions/chromium_extension.py?revision=14872&content-type=text/plain&pathrev=14872
# from: http://grack.com/blog/2009/11/09/packing-chrome-extensions-in-python/
import sys
from array import *
from subprocess import *
import os
import tempfile
def main(argv):
arg0,dir,key,output = argv
# zip up the directory
input = dir + ".zip"
if not os.path.exists(input):
os.system("cd %(dir)s; zip -r ../%(input)s . -x '.svn/*'" % locals())
else:
print "'%s' already exists using it" % input
# Sign the zip file with the private key in PEM format
signature = Popen(["openssl", "sha1", "-sign", key, input], stdout=PIPE).stdout.read();
# Convert the PEM key to DER (and extract the public form) for inclusion in the CRX header
derkey = Popen(["openssl", "rsa", "-pubout", "-inform", "PEM", "-outform", "DER", "-in", key], stdout=PIPE).stdout.read();
out=open(output, "wb");
out.write("Cr24") # Extension file magic number
header = array("l");
header.append(2); # Version 2
header.append(len(derkey));
header.append(len(signature));
header.tofile(out);
out.write(derkey)
out.write(signature)
out.write(open(input).read())
os.unlink(input)
print "Done."
if __name__ == '__main__':
main(sys.argv)
请你能帮助我吗?