util-src/hashes.c

changeset 441
4089b62b510c
parent 432
fb19a5c14d44
child 520
e96ac4bb6dd8
equal deleted inserted replaced
438:193f9dd64f17 441:4089b62b510c
24 size_t len; \ 24 size_t len; \
25 const char *s = luaL_checklstring(L, 1, &len); \ 25 const char *s = luaL_checklstring(L, 1, &len); \
26 int hex_out = lua_toboolean(L, 2); \ 26 int hex_out = lua_toboolean(L, 2); \
27 char hash[size]; \ 27 char hash[size]; \
28 char result[size*2]; \ 28 char result[size*2]; \
29 func(s, len, hash); \ 29 func((const unsigned char*)s, len, (unsigned char*)hash); \
30 if (hex_out) { \ 30 if (hex_out) { \
31 toHex(hash, size, result); \ 31 toHex(hash, size, result); \
32 lua_pushlstring(L, result, size*2); \ 32 lua_pushlstring(L, result, size*2); \
33 } else { \ 33 } else { \
34 lua_pushlstring(L, hash, size);\ 34 lua_pushlstring(L, hash, size);\

mercurial