MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / luaRedisSha1hexCommand

Function luaRedisSha1hexCommand

src/scripting.cpp:875–890  ·  view source on GitHub ↗

This adds redis.sha1hex(string) to Lua scripts using the same hashing * function used for sha1ing lua scripts. */

Source from the content-addressed store, hash-verified

873/* This adds redis.sha1hex(string) to Lua scripts using the same hashing
874 * function used for sha1ing lua scripts. */
875int luaRedisSha1hexCommand(lua_State *lua) {
876 int argc = lua_gettop(lua);
877 char digest[41];
878 size_t len;
879 char *s;
880
881 if (argc != 1) {
882 lua_pushstring(lua, "wrong number of arguments");
883 return lua_error(lua);
884 }
885
886 s = (char*)lua_tolstring(lua,1,&len);
887 sha1hex(digest,s,len);
888 lua_pushstring(lua,digest);
889 return 1;
890}
891
892/* Returns a table with a single field 'field' set to the string value
893 * passed as argument. This helper function is handy when returning

Callers

nothing calls this directly

Calls 5

lua_gettopFunction · 0.85
lua_pushstringFunction · 0.85
lua_errorFunction · 0.85
lua_tolstringFunction · 0.85
sha1hexFunction · 0.85

Tested by

no test coverage detected