mirror of
https://bitbucket.org/jsuto/piler.git
synced 2026-04-05 17:39:20 +02:00
added verification code to the metadata table
This commit is contained in:
18
src/digest.c
18
src/digest.c
@@ -113,3 +113,21 @@ void digest_file(char *filename, char *digest){
|
||||
}
|
||||
|
||||
|
||||
void digest_string(char *s, char *digest){
|
||||
int i;
|
||||
unsigned char md[DIGEST_LENGTH];
|
||||
SHA256_CTX context;
|
||||
|
||||
memset(digest, 0, 2*DIGEST_LENGTH+1);
|
||||
|
||||
SHA256_Init(&context);
|
||||
|
||||
SHA256_Update(&context, s, strlen(s));
|
||||
|
||||
SHA256_Final(md, &context);
|
||||
|
||||
for(i=0;i<DIGEST_LENGTH;i++)
|
||||
snprintf(digest + i*2, 2*DIGEST_LENGTH, "%02x", md[i]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user