]>
git.saurik.com Git - apt.git/blob - apt-pkg/contrib/hashsum_template.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: hashsum_template.h,v 1.3 2001/05/07 05:05:47 jgg Exp $
4 /* ######################################################################
6 HashSumValueTemplate - Generic Storage for a hash value
8 ##################################################################### */
10 #ifndef APTPKG_HASHSUM_TEMPLATE_H
11 #define APTPKG_HASHSUM_TEMPLATE_H
24 unsigned char Sum
[N
/8];
29 bool operator ==(const HashSumValue
&rhs
) const
31 return memcmp(Sum
,rhs
.Sum
,sizeof(Sum
)) == 0;
37 { '0','1','2','3','4','5','6','7','8','9','a','b',
40 char Result
[((N
/8)*2)+1];
43 // Convert each char into two letters
46 for (; I
!= (N
/8)*2; J
++,I
+= 2)
48 Result
[I
] = Conv
[Sum
[J
] >> 4];
49 Result
[I
+ 1] = Conv
[Sum
[J
] & 0xF];
51 return string(Result
);
54 inline void Value(unsigned char S
[N
/8])
56 for (int I
= 0; I
!= sizeof(Sum
); I
++)
60 inline operator string() const
67 return Hex2Num(Str
,Sum
,sizeof(Sum
));
70 inline void Set(unsigned char S
[N
/8])
72 for (int I
= 0; I
!= sizeof(Sum
); I
++)
76 HashSumValue(string Str
)
78 memset(Sum
,0,sizeof(Sum
));
83 memset(Sum
,0,sizeof(Sum
));