File: compute_digest.h

package info (click to toggle)
cado 0.9.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 276 kB
  • sloc: ansic: 1,464; sh: 54; makefile: 16
file content (20 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef _COMPUTE_DIGEST_H
#define _COMPUTE_DIGEST_H
#include <mhash.h>

#define DIGESTTYPE MHASH_SHA256
#define DIGESTLEN (mhash_get_block_size(DIGESTTYPE))
#define DIGESTSTRLEN (2*DIGESTLEN)

/* compute the hash digest.
	 store the result (hex string) in hashstr: an array of at least DIGESTSTRLEN chars
	 return the size of the file in case of success, -1 in case of error */
ssize_t compute_digest(const char *path, char *hashstr);

/* copytemp_hash copies the file whose path is 'inpath' in a temporary file whose path is
	 created by mkstemp using 'outtemplate' */
/* During the copy, copytemp_hash computes the hash and stores the (hex) result in hashstr */
ssize_t copytemp_digest(const char *inpath, char *outtemplate, char *hashstr); 

#endif /* _COMPUTE_DIGEST_H */