I tried the following code:
int hmac_sha1 (const u8 *key, size_t key_len, const u8 *data, size_t data_len, u8 *mac);
static int hmactest( lua_State* L )
{
u8 *key="over9000";
u8 *data="Hello World!";
u8 mac[128];
hmac_sha1(key, os_strlen(key), data, os_strlen(data), mac);
c_printf("the key is %s\n", key);
c_printf("the key length is %d\n", os_strlen(key));
c_printf("the data is %s\n", data);
c_printf("the data length is %d\n", os_strlen(data));
c_printf("the hmac_sha1 string is %s\n", mac);
}
This is the result:
crypto.hmactest()
the key is over9000
the key length is 8
the data is Hello World!
the data length is 12
the hmac_sha1 string is %<�i,��lќ�-`�����#@���?̔$@
> I'm thinking maybe this needs mem_init() just like base64_encode in this post, I tried adding it but had no luck