Skip to content

Instantly share code, notes, and snippets.

@awef
Created March 4, 2012 20:37
Show Gist options
  • Save awef/1974690 to your computer and use it in GitHub Desktop.
Save awef/1974690 to your computer and use it in GitHub Desktop.
Chromeに「パッケージ化されていない拡張機能を読み込む」で拡張を読み込ませた時の拡張IDを算出
#! /usr/bin/env ruby
# Google Chromeの「パッケージ化されていない拡張機能を読み込む」機能で拡張を
# ロードした時のIDを、拡張のディレクトリのパスから割り出す。
# 参考: http://supercollider.dk/2010/01/calculating-chrome-extension-id-from-your-private-key-233
def gen_id (path)
require "digest"
hash = Digest::SHA256.hexdigest(File.absolute_path(path))
hash[0...32].tr("0-9a-f", "a-p")
end
print gen_id(ARGV[0] || gets.rstrip)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment