cctools
sha1.h File Reference

Routines for computing SHA1 checksums. More...

#include <stdint.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  sha1_context_t
 

Functions

void sha1_buffer (const void *buffer, size_t length, unsigned char digest[SHA1_DIGEST_LENGTH])
 Checksum a memory buffer.
 
int sha1_file (const char *path, unsigned char digest[SHA1_DIGEST_LENGTH])
 Checksum a local file.
 
const char * sha1_string (unsigned char digest[SHA1_DIGEST_LENGTH])
 Convert an SHA1 digest into a printable string.
 

Detailed Description

Routines for computing SHA1 checksums.

Function Documentation

◆ sha1_buffer()

void sha1_buffer ( const void * buffer,
size_t length,
unsigned char digest[SHA1_DIGEST_LENGTH] )

Checksum a memory buffer.

Note that this function produces a digest in binary form which must be converted to a human readable form with sha1_string.

Parameters
bufferPointer to a memory buffer.
lengthLength of the buffer in bytes.
digestPointer to a buffer to store the digest.

◆ sha1_file()

int sha1_file ( const char * path,
unsigned char digest[SHA1_DIGEST_LENGTH] )

Checksum a local file.

Note that this function produces a digest in binary form which must be converted to a human readable form with sha1_string.

Parameters
pathPath to the file to checksum.
digestPointer to a buffer to store the digest.
Returns
One on success, zero on failure.

◆ sha1_string()

const char * sha1_string ( unsigned char digest[SHA1_DIGEST_LENGTH])

Convert an SHA1 digest into a printable string.

Parameters
digestA binary digest returned from sha1_file.
Returns
A static pointer to a human readable form of the digest.