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

int main ( int  argc,
char **  argv 
)

Definition at line 91 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.

92 {
93  Octstr *data, *enc;
94 
95  gwlib_init();
96 
97  get_and_set_debugs(argc, argv, NULL);
98 
99  if (argc < 2)
100  panic(0, "Syntax: %s <txt>\n", argv[0]);
101 
102  data = octstr_create(argv[1]);
103  enc = md5(data);
104 
105  debug("",0,"MD5:");
106  octstr_dump(enc, 0);
107 
108  octstr_destroy(enc);
109  enc = md5digest(data);
110 
111  debug("",0,"MD5 (digest):");
112  octstr_dump(enc, 0);
113 
114 #ifdef HAVE_LIBSSL
115  OpenSSL_add_all_digests();
116 
117  octstr_destroy(enc);
118  enc = our_hash_func(data);
119 
120  debug("",0,"SHA1:");
121  octstr_dump(enc, 0);
122 
123  octstr_binary_to_hex(enc, 0);
124  debug("",0,"SHA1 (digest):");
125  octstr_dump(enc, 0);
126 #endif
127 
128  octstr_destroy(data);
129  octstr_destroy(enc);
130  gwlib_shutdown();
131  return 0;
132 }
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:690
#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.