Google Chrome - Alphanumeric hashes to identify extensions

后端 未结 8 712
别那么骄傲
别那么骄傲 2020-11-29 02:17

Google Chrome is using alpha numeric hashes as identifiers for the Chrome extensions. For eg. \"ajpgkpeckebdhofmmjfgcjjiiejpodla\" is the identifier for XMarks Bookmark Sync

8条回答
  •  长情又很酷
    2020-11-29 02:31

    Chromium generates the id via public key. If you use the extension gallery, they handle all that for you.

    From the source:

    bool Extension::GenerateId(const std::string& input, std::string* output) {
      CHECK(output);
      if (input.length() == 0)
        return false;
    
      const uint8* ubuf = reinterpret_cast(input.data());
      SHA256Context ctx;
      SHA256_Begin(&ctx);
      SHA256_Update(&ctx, ubuf, input.length());
      uint8 hash[Extension::kIdSize];
      SHA256_End(&ctx, hash, NULL, sizeof(hash));
      *output = StringToLowerASCII(HexEncode(hash, sizeof(hash)));
      ConvertHexadecimalToIDAlphabet(output);
    
      return true;
    }
    

    Take a look at extension.cc file it has more detailed information such as generating the .pem file exncoding/decoding, etc.

提交回复
热议问题