FOSSology  4.4.0
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

◆ CountDigits()

int CountDigits ( uint64_t  Num)

Count how many digits are in a number.

Parameters
NumNumber
Returns
number of digits

Definition at line 97 of file checksum.c.

◆ SumCloseFile()

void SumCloseFile ( CksumFile CF)

Close a file that was opened with SumOpenFile()

Parameters
CFCksumFile ptr

Definition at line 83 of file checksum.c.

◆ SumComputeBuff()

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 182 of file checksum.c.

◆ SumComputeFile()

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 115 of file checksum.c.

◆ SumOpenFile()

CksumFile* SumOpenFile ( char *  Fname)

Open and mmap a file.

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

Definition at line 26 of file checksum.c.

◆ SumToString()

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 237 of file checksum.c.