页面是用 C 语言生成的,页面里的资源没有 fingerprint 就加载不出来,尝试着用 C 来获得相应资源的 fingerprint,算法都是 sha256,但是得出的值和 rails 生成的不一样,代码如下:
char* sha256_fingerprint(char *filename)
{ unsigned char c[SHA256_DIGEST_LENGTH];
unsigned char fingerprint[SHA256_DIGEST_LENGTH*2];
int i;
FILE *inFile = fopen (filename, "rb");
SHA256_CTX shaContext;
int bytes;
unsigned char data[1024];
SHA256_Init (&shaContext);
while ((bytes = fread (data, 1, 1024, inFile)) != 0)
SHA256_Update (&shaContext, data, bytes);
SHA256_Final (c,&shaContext);
for(i = 0; i < SHA256_DIGEST_LENGTH; i++)
{sprintf(fingerprint+i*2, "%02x", c[i]);}
fclose (inFile);
return fingerprint;
}
或者还有别的办法获取 fingerprint 吗?