谷歌浏览器 - 用于识别扩展的字母数字哈希 [英] Google Chrome - Alphanumeric hashes to identify extensions
问题描述
Google Chrome 使用字母数字哈希作为 Chrome 扩展程序的标识符.例如.ajpgkpeckebdhofmmjfgcjjiiejpodla"是XMarks书签同步扩展的标识符.
Google Chrome is using alpha numeric hashes as identifiers for the Chrome extensions. For eg. "ajpgkpeckebdhofmmjfgcjjiiejpodla" is the identifier for XMarks Bookmark Sync extension.
这里使用哪种算法来生成这样的字符串?他们如何确保唯一性?
Which algorithm is in use here to generate such strings? How are they ensuring uniqueness?
推荐答案
Chromium 通过公钥生成 id.如果您使用扩展程序库,它们会为您处理所有这些.
Chromium generates the id via public key. If you use the extension gallery, they handle all that for you.
来自来源:
bool Extension::GenerateId(const std::string& input, std::string* output) {
CHECK(output);
if (input.length() == 0)
return false;
const uint8* ubuf = reinterpret_cast<const unsigned char*>(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;
}
看看extension.cc文件,里面有更详细的信息,比如生成.pem文件exncoding/decoding等
Take a look at extension.cc file it has more detailed information such as generating the .pem file exncoding/decoding, etc.
这篇关于谷歌浏览器 - 用于识别扩展的字母数字哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!