Misc llcommon tidbits from v2.

This commit is contained in:
Shyotl
2011-03-15 02:28:22 -05:00
parent b06dcb45c0
commit e29d969631
9 changed files with 68 additions and 25 deletions

View File

@@ -192,9 +192,10 @@ void LLMD5::update(std::istream& stream){
}
void LLMD5::update(const std::string& s)
{
update((unsigned char *)s.c_str(),s.length());
}
// MD5 finalization. Ends an MD5 message-digest operation, writing the
// the message digest and zeroizing the context.
@@ -277,7 +278,7 @@ LLMD5::LLMD5(const unsigned char *s)
finalize();
}
void LLMD5::raw_digest(unsigned char *s)
void LLMD5::raw_digest(unsigned char *s) const
{
if (!finalized)
{
@@ -293,7 +294,7 @@ void LLMD5::raw_digest(unsigned char *s)
void LLMD5::hex_digest(char *s)
void LLMD5::hex_digest(char *s) const
{
int i;
@@ -327,13 +328,25 @@ std::ostream& operator<<(std::ostream &stream, LLMD5 context)
return stream;
}
bool operator==(const LLMD5& a, const LLMD5& b)
{
unsigned char a_guts[16];
unsigned char b_guts[16];
a.raw_digest(a_guts);
b.raw_digest(b_guts);
if (memcmp(a_guts,b_guts,16)==0)
return true;
else
return false;
}
bool operator!=(const LLMD5& a, const LLMD5& b)
{
return !(a==b);
}
// PRIVATE METHODS:
void LLMD5::init(){
finalized=0; // we just started!