2 commandline/nacl-sha512.c version 20080713
14 #include "crypto_hash_sha512.h"
17 unsigned long long inputalloc
;
18 unsigned long long inputlen
;
20 unsigned char h
[crypto_hash_sha512_BYTES
];
25 for (i
= 0;i
< crypto_hash_sha512_BYTES
;++i
) printf("%02x",255 & (int) h
[i
]);
34 if (fstat(0,&st
) == 0) {
35 input
= mmap(0,st
.st_size
,PROT_READ
,MAP_SHARED
,0,0);
36 if (input
!= MAP_FAILED
) {
37 crypto_hash_sha512(h
,input
,st
.st_size
);
47 while ((ch
= getchar()) != EOF
) {
48 if (inputlen
>= inputalloc
) {
50 while (inputlen
>= inputalloc
)
51 inputalloc
= inputalloc
* 2 + 1;
52 if (posix_memalign(&newinput
,16,inputalloc
) != 0) return 111;
53 memcpy(newinput
,input
,inputlen
);
57 input
[inputlen
++] = ch
;
60 crypto_hash_sha512(h
,input
,inputlen
);