MD5.h
 1  #ifndef MD5_h
 2  #define MD5_h
 3  
 4  #include "Arduino.h"
 5  
 6  /*
 7   * This is an OpenSSL-compatible implementation of the RSA Data Security,
 8   * Inc. MD5 Message-Digest Algorithm (RFC 1321).
 9   *
10   * Written by Solar Designer <solar at openwall.com> in 2001, and placed
11   * in the public domain.  There's absolutely no warranty.
12   *
13   * This differs from Colin Plumb's older public domain implementation in
14   * that no 32-bit integer data type is required, there's no compile-time
15   * endianness configuration, and the function prototypes match OpenSSL's.
16   * The primary goals are portability and ease of use.
17   *
18   * This implementation is meant to be fast, but not as fast as possible.
19   * Some known optimizations are not included to reduce source code size
20   * and avoid compile-time configuration.
21   */
22  
23  /*
24   * Updated by Scott MacVicar for arduino
25   * <scott@macvicar.net>
26   */
27  
28  #include <string.h>
29  
30  typedef unsigned long MD5_u32plus;
31  
32  typedef struct {
33  	MD5_u32plus lo, hi;
34  	MD5_u32plus a, b, c, d;
35  	unsigned char buffer[64];
36  	MD5_u32plus block[16];
37  } MD5_CTX;
38  
39  class MD5
40  {
41  public:
42  	MD5();
43  	static unsigned char* make_hash(char *arg);
44  	static unsigned char* make_hash(char *arg,size_t size);
45  	static char* make_digest(const unsigned char *digest, int len);
46   	static const void *body(void *ctxBuf, const void *data, size_t size);
47  	static void MD5Init(void *ctxBuf);
48  	static void MD5Final(unsigned char *result, void *ctxBuf);
49  	static void MD5Update(void *ctxBuf, const void *data, size_t size);
50  };
51  
52  #endif