[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Detecting any changes in a set of Lua objects from C
- From: Marc Balmer <marc@...>
- Date: Fri, 4 Jan 2013 21:57:53 +0100
> I was thinking about checksums earlier for another reason (to hash a lot of table values into one key value). You're right that could occur here.
>
> Are there any examples of this being done that I could look at?
probably the easiest way is to use openssl for that.
EVP_MD_CTX ctx;
int len;
char *digest;
digest = malloc(EVP_MAX_MD_SIZE);
if (digest == NULL)
return -1;
EVP_DigestInit(&ctx, EVP_sha256());
/* For each data element */
EVP_DigestUpdate(&ctx, element, strlen(element));
EVP_DigestFinal(&ctx, digest, &len);
/* digest now contains the SHA256 hash */
Check the docs.