MCPcopy Create free account
hub / github.com/apache/httpd / lua_apr_sha1

Function lua_apr_sha1

modules/lua/lua_request.c:969–989  ·  view source on GitHub ↗

* lua_apr_sha1; r:sha1(string) - Calculates the SHA1 digest of a string */

Source from the content-addressed store, hash-verified

967 * lua_apr_sha1; r:sha1(string) - Calculates the SHA1 digest of a string
968 */
969static int lua_apr_sha1(lua_State *L)
970{
971 unsigned char digest[APR_SHA1_DIGESTSIZE];
972 apr_sha1_ctx_t sha1;
973 const char *buffer;
974 char *result;
975 size_t len;
976 request_rec *r;
977
978 r = ap_lua_check_request_rec(L, 1);
979 luaL_checktype(L, 2, LUA_TSTRING);
980 result = apr_pcalloc(r->pool, sizeof(digest) * 2 + 1);
981 buffer = lua_tolstring(L, 2, &len);
982 apr_sha1_init(&sha1);
983 apr_sha1_update(&sha1, buffer, len);
984 apr_sha1_final(digest, &sha1);
985
986 ap_bin2hex(digest, sizeof(digest), result);
987 lua_pushstring(L, result);
988 return 1;
989}
990
991/*
992 * lua_apr_htpassword; r:htpassword(string [, algorithm [, cost]]) - Creates

Callers

nothing calls this directly

Calls 2

ap_bin2hexFunction · 0.85
ap_lua_check_request_recFunction · 0.70

Tested by

no test coverage detected