FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
checksum.c File Reference

Code to compute a three part checksum: SHA1.MD5.Size. More...

#include <gcrypt.h>
#include "checksum.h"
Include dependency graph for checksum.c:

Go to the source code of this file.

Functions

CksumFileSumOpenFile (char *Fname)
 Open and mmap a file. More...
 
void SumCloseFile (CksumFile *CF)
 Close a file that was opened with SumOpenFile() More...
 
int CountDigits (uint64_t Num)
 Count how many digits are in a number. More...
 
CksumSumComputeFile (FILE *Fin)
 Compute the checksum, allocate and return a string containing the sum value. More...
 
CksumSumComputeBuff (CksumFile *CF)
 Compute the checksum, allocate and return a Cksum containing the sum value. More...
 
char * SumToString (Cksum *Sum)
 Return string representing a Cksum. NOTE: The calling function must free() the string! More...
 
int calc_sha256sum (char *filename, char *dst)
 

Detailed Description

Code to compute a three part checksum: SHA1.MD5.Size.

  • SHA1 = SHA1 of the file.
  • MD5 = MD5 value of the file.
  • Size = number of bytes in the file. The chances of two files having the same size, same MD5, and same SHA1 is extremely unlikely.

Definition in file checksum.c.

Function Documentation

int CountDigits ( uint64_t  Num)

Count how many digits are in a number.

Parameters
NumNumber
Returns
number of digits

Definition at line 109 of file checksum.c.

void SumCloseFile ( CksumFile CF)

Close a file that was opened with SumOpenFile()

Parameters
CFCksumFile ptr

Definition at line 95 of file checksum.c.

Cksum* SumComputeBuff ( CksumFile CF)

Compute the checksum, allocate and return a Cksum containing the sum value.

Note
The calling function must free() the returned Cksum!
Parameters
CFCksumFile ptr
Returns
Cksum or NULL on error.

Definition at line 194 of file checksum.c.

Cksum* SumComputeFile ( FILE *  Fin)

Compute the checksum, allocate and return a string containing the sum value.

Note
The calling function must free() the string!
Parameters
FinOpen file descriptor
Returns
NULL on error.

Definition at line 127 of file checksum.c.

CksumFile* SumOpenFile ( char *  Fname)

Open and mmap a file.

Parameters
FnameFile pathname
Returns
CksmFile ptr, or NULL on failure.

Definition at line 38 of file checksum.c.

char* SumToString ( Cksum Sum)

Return string representing a Cksum. NOTE: The calling function must free() the string!

Parameters
SumCksum ptr
Returns
"sha1.md5.size" string, or NULL on error.

Definition at line 249 of file checksum.c.