All pastes #75373 Raw Edit

Someone

public text v1 · immutable
#75373 ·published 2006-06-30 03:04 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>

#include "nessie.h"

main(int argc, char **argv) {
    struct NESSIEstruct whirlpool_ctx;
    int desc, readed, counter;
    char buf[4100];
    char digest[72];

    if(argc != 2) {
        printf("Usage: whirlpool {filename}\n");
        exit(1);
        }

    if((desc = open(argv[1],O_RDONLY)) < 0) {
        perror("Could not open file");
        exit(2);
        }

    NESSIEinit(&whirlpool_ctx);

    readed = 1;
    while(readed > 0) {
        readed = read(desc,buf,4096);
        if(readed > 0)
            NESSIEadd(buf,readed * 8,&whirlpool_ctx);
        }

    NESSIEfinalize(&whirlpool_ctx,digest);

    printf("Whirlpool digest: ");
    for(counter = 0; counter < 64; counter++)
        printf("%02x",digest[counter] & 0xff);
    printf("\n");

    }