This adds redis.sha1hex(string) to Lua scripts using the same hashing * function used for sha1ing lua scripts. */
| 873 | /* This adds redis.sha1hex(string) to Lua scripts using the same hashing |
| 874 | * function used for sha1ing lua scripts. */ |
| 875 | int 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 |
nothing calls this directly
no test coverage detected