File: SHA256Ident.c

package info (click to toggle)
open-plc-utils 0.0.6%2Bgit20230504.1ba7d5a0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 17,212 kB
  • sloc: ansic: 60,875; xml: 16,179; sh: 1,216; makefile: 698
file content (41 lines) | stat: -rw-r--r-- 944 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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*====================================================================*
 *
 *   void SHA256Ident (signed fd,  uint8_t digest []);
 *
 *   SHA256.h
 *
 *   compute the SHA256 digest of file content; the digest becomes
 *   the fingerprint that can be used to identify the file despite
 *   filename changes;
 *
 *   Motley Tools by Charles Maier;
 *   Copyright (c) 2001-2006 by Charles Maier Associates;
 *   Licensed under the Internet Software Consortium License;
 *
 *--------------------------------------------------------------------*/

#ifndef SHA256IDENT_SOURCE
#define SHA256IDENT_SOURCE

#include <unistd.h>

#include "../key/SHA256.h"

void SHA256Ident (signed fd, uint8_t digest [])

{
	struct sha256 sha256;
	uint8_t buffer [1024];
	signed length;
	SHA256Reset (&sha256);
	while ((length = read (fd, buffer, sizeof (buffer))) > 0)
	{
		SHA256Write (&sha256, buffer, length);
	}
	SHA256Fetch (&sha256, digest);
	return;
}


#endif