/* Calculates raw SHA1 hash of input string. Input is arbitrary string, output is raw 20-byte hash as string.  */
static int crypto_sha1(lua_State *L)
/* Calculates raw SHA1 hash of input string. Input is arbitrary string, output is raw 20-byte hash as string.  */
static int crypto_sha1(lua_State *L)
{
  SHA1_CTX ctx;
  uint8_t digest[20];
  int len;
  const char* msg = luaL_checklstring(L, 1, &len);
  SHA1Init(&ctx);
  SHA1Update(&ctx, msg, len);
  SHA1Final(digest, &ctx);
  lua_pushlstring(L, digest, 20);
  return 1;
}