Plan 9 from Bell Labs’s /usr/web/sources/contrib/mycroftiv/unreleased/hashfuncs/crypthashdem.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/* 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 */

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.