/* given a number representing hashtable size and additional data arguments, crypthashdem will produce correctly sized hashes based on sha1 and md5 algorithms */
/* EXAMPLE: crypthashdem 1000 foo bar baz */
#include <u.h>
#include <libc.h>
#include <ctype.h>
#include <mp.h>
#include <libsec.h>
#include "crypthash.c"
void
main(int argc, char **argv)
{
uint ntbl;
uint hashout;
if((argc < 3) || (isdigit(*(argv[1])) == 0)){
print("usage: crypthashdem tablesize hashme1 [hashme2] [hashme3] ... \n");
exits(nil);
}
ntbl = atoi(argv[1]);
print("\tsha1 based hashes\n");
for(int i = 2; i < argc; i++){
hashout = sha1hash(ntbl, argv[i]);
print("%s : %ud\n", argv[i], hashout);
}
print("\tmd5 based hashes\n");
for(int i = 2; i < argc; i++){
hashout = md5hash(ntbl, argv[i]);
print("%s : %ud\n", argv[i], hashout);
}
exits(nil);
}
/* implemented by mycroftiv */
|