lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



> 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.