本文介绍了用PHP创建Google Chrome Crx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Id喜欢用PHP生成一个crx文件。Id like to be able to generate a crx file with PHP.一个crx文件是一个带有额外头文件的zip文件,创建这个头。如果我使用预生成的pem文件,我可以创建一个crx文件,但这会导致所有crx文件具有相同的扩展名,并且这不太好。下面是我到目前为止所得到的链接..... http://valorsolo.com/index.php?page=Viewing%20Message&id=1472&pagenum=2#1500 A crx file is a zip file with an additional header and Im at a lost on how to create this header. I can create a crx file if I use a pregenerated pem file but this leads to all the crx files having the same extension id and this is not good. Heres a link to what Ive got so far.....http://valorsolo.com/index.php?page=Viewing%20Message&id=1472&pagenum=2#1500 Incase它帮助这已经在Python中完成,并有一个很好的博客文章,在这里更详细的细节.... http://blog.roomanna.com/12-12-2010/packaging-chrome-extensions 和heres某些指向其他代码的链接关于该主题..... http://code.google.com/chrome /extensions/crx.html http ://code.google.com/p/crx-packaging/source/browse/trunk/packer.py https://github.com/bellbind/crxmake-python/blob/mas ter / crxmake.py http://www.curetheitch.com/projects/buildcrx / Incase it helps this has been done in Python and there is an excellent blog post on the finer details here....http://blog.roomanna.com/12-12-2010/packaging-chrome-extensionsand heres some links to other code on the subject.....http://code.google.com/chrome/extensions/crx.htmlhttp://code.google.com/p/crx-packaging/source/browse/trunk/packer.pyhttps://github.com/bellbind/crxmake-python/blob/master/crxmake.pyhttp://www.curetheitch.com/projects/buildcrx/推荐答案 ruby code 很有用。您的公钥必须是DER格式,不幸的是PHP据我所知,OpenSSL扩展无法做到这一点。我必须从命令行的私钥生成它:Your public key must be in DER format, and unfortunately PHP's OpenSSL extension can't do that, so far as I can tell. I had to generate it from my private key at the command line:openssl rsa -pubout -outform DER < extension_private_key.pem > extension_public_key.pub UPDATE :有一个PHP der2pem()函数可以在这里下载,感谢tutuDajuju指出它。UPDATE: there is a PHP der2pem() function available here, thanks to tutuDajuju for pointing it out.完成后,构建.crx文件非常简单: Once that's done, building the .crx file is quite easy:# make a SHA1 signature using our private key$pk = openssl_pkey_get_private(file_get_contents('extension_private_key.pem'));openssl_sign(file_get_contents('extension.zip'), $signature, $pk, 'sha1');openssl_free_key($pk);# decode the public key$key = base64_decode(file_get_contents('extension_public_key.pub'));# .crx package format:## magic number char(4)# crx format ver byte(4)# pub key lenth byte(4)# signature length byte(4)# public key string# signature string# package contents, zipped string## see http://code.google.com/chrome/extensions/crx.html#$fh = fopen('extension.crx', 'wb');fwrite($fh, 'Cr24'); // extension file magic numberfwrite($fh, pack('V', 2)); // crx format versionfwrite($fh, pack('V', strlen($key))); // public key lengthfwrite($fh, pack('V', strlen($signature))); // signature lengthfwrite($fh, $key); // public keyfwrite($fh, $signature); // signaturefwrite($fh, file_get_contents('extension.zip')); // package contents, zippedfclose($fh); 这篇关于用PHP创建Google Chrome Crx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-26 18:16