This adds redis.sha1hex(string) to Lua scripts using the same hashing * function used for sha1ing lua scripts. */
| 859 | /* This adds redis.sha1hex(string) to Lua scripts using the same hashing |
| 860 | * function used for sha1ing lua scripts. */ |
| 861 | int luaRedisSha1hexCommand(lua_State *lua) { |
| 862 | int argc = lua_gettop(lua); |
| 863 | char digest[41]; |
| 864 | size_t len; |
| 865 | char *s; |
| 866 | |
| 867 | if (argc != 1) { |
| 868 | lua_pushstring(lua, "wrong number of arguments"); |
| 869 | return lua_error(lua); |
| 870 | } |
| 871 | |
| 872 | s = (char*)lua_tolstring(lua,1,&len); |
| 873 | sha1hex(digest,s,len); |
| 874 | lua_pushstring(lua,digest); |
| 875 | return 1; |
| 876 | } |
| 877 | |
| 878 | /* Returns a table with a single field 'field' set to the string value |
| 879 | * passed as argument. This helper function is handy when returning |
nothing calls this directly
no test coverage detected