1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
14 Hash a file, Tom St Denis
18 @param hash The index of the hash desired
19 @param fname The name of the file you wish to hash
20 @param out [out] The destination of the digest
21 @param outlen [in/out] The max size and resulting size of the message digest
22 @result CRYPT_OK if successful
24 int hash_file(int hash, const char *fname, unsigned char *out, unsigned long *outlen)
28 LTC_ARGCHK(fname != NULL);
29 LTC_ARGCHK(out != NULL);
30 LTC_ARGCHK(outlen != NULL);
32 if ((err = hash_is_valid(hash)) != CRYPT_OK) {
36 in = fopen(fname, "rb");
38 return CRYPT_FILE_NOTFOUND;
41 err = hash_filehandle(hash, in, out, outlen);
42 if (fclose(in) != 0) {
48 #endif /* #ifndef LTC_NO_FILE */
51 /* ref: $Format:%D$ */
52 /* git commit: $Format:%H$ */
53 /* commit time: $Format:%ai$ */