|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /proc/21571/root/usr/share/doc/mhash-devel-0.9.9/ |
Upload File : |
/* Example program that uses mhash to hash stdin using MD5 */
#include <mhash.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int i;
MHASH td;
unsigned char buffer;
unsigned char hash[16]; /* only for md5 */
td = mhash_init(MHASH_MD5);
if (td == MHASH_FAILED) exit(1);
while (fread(&buffer, 1, 1, stdin) == 1) {
mhash(td, &buffer, 1);
}
mhash_deinit(td, hash);
printf("Hash:");
for (i = 0; i < mhash_get_block_size(MHASH_MD5); i++) {
printf("%.2x", hash[i]);
}
printf("\n");
exit(0);
}