Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tools/crx_id/crx_id.py

Issue 12385037: Add HasPublicKey to crx_id. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rename from_test_path to from_file_path Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/crx_id/crx_id_unittest.py » ('j') | tools/crx_id/crx_id_unittest.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/crx_id/crx_id.py
===================================================================
--- tools/crx_id/crx_id.py (revision 185325)
+++ tools/crx_id/crx_id.py (working copy)
@@ -95,8 +95,15 @@
else:
return base64.standard_b64decode(manifest['key'])
-def GetPublicKey(filename, from_test_path):
- if from_test_path:
+def HasPublicKey(filename):
+ if os.path.isdir(filename):
+ with open(os.path.join(filename, 'manifest.json'), 'rb') as f:
+ manifest = json.load(f)
+ return 'key' in manifest
+ return False
+
+def GetPublicKey(filename, from_file_path):
+ if from_file_path:
return GetPublicKeyFromPath(filename)
pub_key = ''
@@ -112,13 +119,13 @@
f.close()
return pub_key
-def GetCRXHash(filename, from_test_path=False):
- pub_key = GetPublicKey(filename, from_test_path)
+def GetCRXHash(filename, from_file_path=False):
+ pub_key = GetPublicKey(filename, from_file_path)
pub_key_hash = hashlib.sha256(pub_key).digest()
return HexTo256(pub_key_hash)
-def GetCRXAppID(filename, from_test_path=False):
- pub_key = GetPublicKey(filename, from_test_path)
+def GetCRXAppID(filename, from_file_path=False):
+ pub_key = GetPublicKey(filename, from_file_path)
pub_key_hash = hashlib.sha256(pub_key).digest()
# AppID is the MPDecimal of only the first 128 bits of the hash.
return HexToMPDecimal(pub_key_hash[:128/8])
« no previous file with comments | « no previous file | tools/crx_id/crx_id_unittest.py » ('j') | tools/crx_id/crx_id_unittest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698