Module: Extensionator::CRX
- Defined in:
- lib/extensionator/crx.rb
Class Method Summary collapse
- .create(destination, zip_str, priv_key) ⇒ Object
- .format_size(num) ⇒ Object
- .sign(zip_str, priv_key) ⇒ Object
- .write_crx(destination, zip_str, sig_bytes, priv_key) ⇒ Object
Class Method Details
.create(destination, zip_str, priv_key) ⇒ Object
6 7 8 9 |
# File 'lib/extensionator/crx.rb', line 6 def self.create(destination, zip_str, priv_key) sig_bytes = sign(zip_str, priv_key) write_crx(destination, zip_str, sig_bytes, priv_key) end |
.format_size(num) ⇒ Object
30 31 32 |
# File 'lib/extensionator/crx.rb', line 30 def self.format_size(num) [num].pack("V") end |
.sign(zip_str, priv_key) ⇒ Object
11 12 13 |
# File 'lib/extensionator/crx.rb', line 11 def self.sign(zip_str, priv_key) priv_key.sign(OpenSSL::Digest::SHA1.new, zip_str) end |
.write_crx(destination, zip_str, sig_bytes, priv_key) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/extensionator/crx.rb', line 15 def self.write_crx(destination, zip_str, sig_bytes, priv_key) pub_key_bytes = priv_key.public_key.to_der #See https://developer.chrome.com/extensions/crx for the format description File.open(destination, "wb") do |file| file << "Cr24" file << format_size(2) file << format_size(pub_key_bytes.size) file << format_size(sig_bytes.size) file << pub_key_bytes file << sig_bytes file << zip_str end end |