From a67fdaa1ef1e3a5eea88d19e327c05330998e8aa Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 31 Oct 2006 05:41:13 +0000 Subject: Added an sha1 class... --- src/sha1.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/sha1.h (limited to 'src/sha1.h') diff --git a/src/sha1.h b/src/sha1.h new file mode 100644 index 0000000..ab6081d --- /dev/null +++ b/src/sha1.h @@ -0,0 +1,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 + +/** + * 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 -- cgit v1.2.3