Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

Md5stream Class Reference

#include <cxxtools/md5stream.h>

List of all members.

Public Types

typedef
std::ostreambuf_iterator< char > 
iterator

Public Member Functions

 Md5stream ()
 initializes md5-calculation
void getDigest (unsigned char digest[16])
 ends md5-calculation and returns 16 bytes digest
const char * getHexDigest ()
 ends md5-calculation and digest as 32 bytes hex
iterator begin ()
 returns output-iterator to Md5stream


Detailed Description

This is a easy and safe interface to MD5-calculation.

To get a MD5-sum of data, instantiate a md5stream, copy your data into it and read the digest.

After calling getDigest or getHexDigest, the class can be reused for another md5-calculation. The algorithm is automatically reinitialized when the first character is received.

example:

  int main(int argc, char* argv[])
  {
    Md5stream s;
    for (int i = 1; i < argc; ++i)
    {
      std::ifstream in(argv[i]);
      if (in)
      {
        s << in.rdbuf();
        std::cout << s.getHexDigest() << "  " << argv[i] << std::endl;
      }
    }
  }
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6