aboutsummaryrefslogtreecommitdiff
path: root/src/old/sha1.h
blob: ab6081d438433b0de980dbe5d0a87216836da926 (plain)
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
42
/* sha1.h

Copyright (c) 2005 Michael D. Leonhard

http://tamale.net/

This file is licensed under the terms described in the
accompanying LICENSE file.
*/

#ifndef SHA1_H
#define SHA1_H

#include <stdint.h>

/**
 * Calculates SHA-1 sums.  This is based strongly on code from Michael D.
 * Leonhard who released his code under the terms of the MIT license, thank you!
 */
class Sha1
{
public:
	Sha1();
	~Sha1();

	void update( const char* data, int num );
	unsigned char* getDigest();

	// utility methods
	static uint32_t lrot( uint32_t x, int bits );
	static void toBigEndian( uint32_t in, unsigned char* out );

private:
	// fields
	uint32_t H0, H1, H2, H3, H4;
	unsigned char bytes[64];
	int unprocessedBytes;
	uint32_t size;
	void process();
};

#endif