Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
test_hash.c File Reference
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include "gwlib/gwlib.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 104 of file test_hash.c.

References debug(), get_and_set_debugs(), gwlib_init(), gwlib_shutdown(), md5(), md5digest(), octstr_binary_to_hex(), octstr_create, octstr_destroy(), octstr_dump, our_hash_func(), and panic.

105 {
106  Octstr *data, *enc;
107 
108  gwlib_init();
109 
110  get_and_set_debugs(argc, argv, NULL);
111 
112  if (argc < 2)
113  panic(0, "Syntax: %s <txt>\n", argv[0]);
114 
115  data = octstr_create(argv[1]);
116  enc = md5(data);
117 
118  debug("",0,"MD5:");
119  octstr_dump(enc, 0);
120 
121  octstr_destroy(enc);
122  enc = md5digest(data);
123 
124  debug("",0,"MD5 (digest):");
125  octstr_dump(enc, 0);
126 
127 #ifdef HAVE_LIBSSL
128  OpenSSL_add_all_digests();
129 
130  octstr_destroy(enc);
131  enc = our_hash_func(data);
132 
133  debug("",0,"SHA1:");
134  octstr_dump(enc, 0);
135 
136  octstr_binary_to_hex(enc, 0);
137  debug("",0,"SHA1 (digest):");
138  octstr_dump(enc, 0);
139 #endif
140 
141  octstr_destroy(data);
142  octstr_destroy(enc);
143  gwlib_shutdown();
144  return 0;
145 }
Octstr * md5(Octstr *data)
Definition: md5.c:387
static Octstr * our_hash_func(Octstr *os)
Definition: dlr_spool.c:123
void octstr_binary_to_hex(Octstr *ostr, int uppercase)
Definition: octstr.c:463
#define octstr_dump(ostr, level,...)
Definition: octstr.h:564
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define octstr_create(cstr)
Definition: octstr.h:125
Definition: octstr.c:118
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
#define panic
Definition: log.h:87
void gwlib_shutdown(void)
Definition: gwlib.c:94
void gwlib_init(void)
Definition: gwlib.c:78
int get_and_set_debugs(int argc, char **argv, int(*find_own)(int index, int argc, char **argv))
Definition: utils.c:626
Octstr * md5digest(Octstr *data)
Definition: md5.c:406
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.