]>
git.saurik.com Git - apt-legacy.git/blob - apt-pkg/contrib/md5.h
afa448ad78031dd50c078ed06e3588203aa6c2a9
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: md5.h,v 1.6 2001/05/07 05:06:52 jgg Exp $
4 /* ######################################################################
6 MD5SumValue - Storage for a MD5Sum
7 MD5Summation - MD5 Message Digest Algorithm.
9 This is a C++ interface to a set of MD5Sum functions. The class can
10 store a MD5Sum in 16 bytes of memory.
12 A MD5Sum is used to generate a (hopefully) unique 16 byte number for a
13 block of data. This can be used to gaurd against corruption of a file.
14 MD5 should not be used for tamper protection, use SHA or something more
17 There are two classes because computing a MD5 is not a continual
18 operation unless 64 byte blocks are used. Also the summation requires an
19 extra 18*4 bytes to operate.
21 ##################################################################### */
32 #include <apt-pkg/srkstring.h>
41 friend class MD5Summation
;
42 unsigned char Sum
[4*4];
47 bool operator ==(const MD5SumValue
&rhs
) const;
49 inline void Value(unsigned char S
[16])
50 {for (int I
= 0; I
!= sizeof(Sum
); I
++) S
[I
] = Sum
[I
];};
51 inline operator string() const {return Value();};
53 bool Set(const srkString
&Str
);
54 inline void Set(unsigned char S
[16])
55 {for (int I
= 0; I
!= sizeof(Sum
); I
++) Sum
[I
] = S
[I
];};
57 MD5SumValue(string Str
);
58 MD5SumValue(const srkString
&Str
);
65 unsigned char Bytes
[2*4];
66 unsigned char In
[16*4];
71 bool Add(const unsigned char *Data
,unsigned long Size
);
72 inline bool Add(const char *Data
) {return Add((unsigned char *)Data
,strlen(Data
));};
73 bool AddFD(int Fd
,unsigned long Size
);
74 inline bool Add(const unsigned char *Beg
,const unsigned char *End
)
75 {return Add(Beg
,End
-Beg
);};