Blender V2.61 - r43446

util_md5.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1999, 2002 Aladdin Enterprises.  All rights reserved.
00003  *
00004  * This software is provided 'as-is', without any express or implied
00005  * warranty.  In no event will the authors be held liable for any damages
00006  * arising from the use of this software.
00007  *
00008  * Permission is granted to anyone to use this software for any purpose,
00009  * including commercial applications, and to alter it and redistribute it
00010  * freely, subject to the following restrictions:
00011  *
00012  * 1. The origin of this software must not be misrepresented; you must not
00013  *    claim that you wrote the original software. If you use this software
00014  *    in a product, an acknowledgment in the product documentation would be
00015  *    appreciated but is not required.
00016  * 2. Altered source versions must be plainly marked as such, and must not be
00017  *    misrepresented as being the original software.
00018  * 3. This notice may not be removed or altered from any source distribution.
00019  *
00020  * L. Peter Deutsch
00021  * ghost@aladdin.com
00022  */
00023 
00024 /* MD5
00025  *
00026  * Simply MD5 hash computation, used by disk cache. Adapted from external
00027  * code, with minor code modifications done to remove some unused code and
00028  * change code style. */
00029 
00030 #ifndef __UTIL_MD5_H__
00031 #define __UTIL_MD5_H__
00032 
00033 #include "util_string.h"
00034 #include "util_types.h"
00035 
00036 CCL_NAMESPACE_BEGIN
00037 
00038 class MD5Hash {
00039 public:
00040     MD5Hash();
00041     ~MD5Hash();
00042 
00043     void append(const uint8_t *data, int size);
00044     bool append_file(const string& filepath);
00045     string get_hex();
00046 
00047 protected:
00048     void process(const uint8_t *data);
00049     void finish(uint8_t digest[16]);
00050 
00051     uint32_t count[2]; /* message length in bits, lsw first */
00052     uint32_t abcd[4]; /* digest buffer */
00053     uint8_t buf[64]; /* accumulate block */
00054 };
00055 
00056 CCL_NAMESPACE_END
00057 
00058 #endif /* __UTIL_MD5_H__ */
00059