2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2003-12-13 00:06:00 +00:00
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2003-12-13 00:06:00 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-02-18 01:34:18 +00:00
|
|
|
*
|
2003-12-13 00:06:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COMMON_MD5_H
|
|
|
|
#define COMMON_MD5_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
|
2005-05-10 22:56:25 +00:00
|
|
|
namespace Common {
|
|
|
|
|
2020-07-08 21:30:36 +00:00
|
|
|
/**
|
|
|
|
* @defgroup common_md5 MD5 checksum
|
|
|
|
* @ingroup common
|
|
|
|
*
|
|
|
|
* @brief API for computing the MD5 checksum.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2008-09-03 11:22:51 +00:00
|
|
|
class ReadStream;
|
2011-04-24 08:34:27 +00:00
|
|
|
class String;
|
2008-09-03 11:22:51 +00:00
|
|
|
|
2010-11-07 17:16:59 +00:00
|
|
|
/**
|
|
|
|
* Compute the MD5 checksum of the content of the given ReadStream.
|
|
|
|
* The 128 bit MD5 checksum is returned directly in the array digest.
|
|
|
|
* If length is set to a positive value, then only the first length
|
|
|
|
* bytes of the stream are used to compute the checksum.
|
|
|
|
* @param[in] stream the stream of whose data the MD5 is computed
|
|
|
|
* @param[out] digest the computed MD5 checksum
|
|
|
|
* @param[in] length the number of bytes for which to compute the checksum; 0 means all
|
|
|
|
* @return true on success, false if an error occurred
|
|
|
|
*/
|
|
|
|
bool computeStreamMD5(ReadStream &stream, uint8 digest[16], uint32 length = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute the MD5 checksum of the content of the given ReadStream.
|
|
|
|
* The 128 bit MD5 checksum is converted to a human readable
|
|
|
|
* lowercase hex string of length 32.
|
|
|
|
* If length is set to a positive value, then only the first length
|
|
|
|
* bytes of the stream are used to compute the checksum.
|
|
|
|
* @param[in] stream the stream of whose data the MD5 is computed
|
|
|
|
* @param[in] length the number of bytes for which to compute the checksum; 0 means all
|
|
|
|
* @return the MD5 as a hex string on success, and an empty string if an error occurred
|
|
|
|
*/
|
|
|
|
String computeStreamMD5AsString(ReadStream &stream, uint32 length = 0);
|
2007-02-14 21:43:21 +00:00
|
|
|
|
2020-07-08 21:30:36 +00:00
|
|
|
/** @} */
|
|
|
|
|
2005-05-10 22:56:25 +00:00
|
|
|
} // End of namespace Common
|
|
|
|
|
2003-12-13 00:06:00 +00:00
|
|
|
#endif
|