#include "cmd_sha1.h" void *cmd_sha1(void *data) { char *param = (char *)data; char *ret = NULL; int i; char hash_result[21]; char hex_result[41]; const int buf_size = 128; char buf[buf_size+1]; printf("SHA1\n"); if (param == NULL) { ret = alloc_new_str("No params mate\n"); return ret; } SHA1(hash_result, param, strlen(param)); //cool way how to convert array to string for (i=0;i<20;i++) { sprintf(hex_result+(2*i), "%02x", hash_result[i]&0xff); } hex_result[40]=0x0; snprintf(buf, buf_size, "sha1 %s",hex_result); ret = alloc_new_str(buf); return ret; }