~ubuntu-branches/ubuntu/maverick/notecase/maverick

« back to all changes in this revision

Viewing changes to src/lib/SHA1.h

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2005-09-09 09:32:43 UTC
  • Revision ID: james.westby@ubuntu.com-20050909093243-s6namw0yh7q3tqy0
Tags: upstream-1.0.5
ImportĀ upstreamĀ versionĀ 1.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////
 
2
// NoteCase notes manager project <http://notecase.sf.net>
 
3
//
 
4
// This code is licensed under BSD license.See "license.txt" for more details.
 
5
//
 
6
// File: Class implements SHA1 hashing algorithm
 
7
////////////////////////////////////////////////////////////////////////////
 
8
 
 
9
/*
 
10
        100% free public domain implementation of the SHA-1 algorithm
 
11
 
 
12
        === Test Vectors (from FIPS PUB 180-1) ===
 
13
 
 
14
        "abc"
 
15
                A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
 
16
 
 
17
        "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
 
18
                84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
 
19
 
 
20
        A million repetitions of "a"
 
21
                34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
 
22
*/
 
23
 
 
24
#ifndef _SHA1_H___
 
25
#define _SHA1_H___
 
26
 
 
27
#ifndef LITTLE_ENDIAN
 
28
 #define LITTLE_ENDIAN
 
29
#endif
 
30
 
 
31
#define MAX_FILE_READ_BUFFER 8000
 
32
 
 
33
class CSHA1
 
34
{
 
35
    public:
 
36
        enum { REPORT_HEX = 0, REPORT_DIGIT = 1 };
 
37
 
 
38
        CSHA1 ();
 
39
        virtual ~CSHA1 ();
 
40
 
 
41
        unsigned long m_state[5];
 
42
        unsigned long m_count[2];
 
43
        unsigned char m_buffer[64];
 
44
        unsigned char m_digest[20];
 
45
 
 
46
        void Reset ();
 
47
 
 
48
        void Update (unsigned char* data, unsigned int len);
 
49
        bool HashFile (char *szFileName);
 
50
 
 
51
        void Final ();
 
52
        void ReportHash (char *szReport, unsigned char uReportType = REPORT_HEX);
 
53
        void GetHash (unsigned char *uDest);
 
54
 
 
55
    private:
 
56
        void Transform (unsigned long state[5], unsigned char buffer[64]);
 
57
};
 
58
 
 
59
#endif