// implied warranty of any kind.
//
// The translators/modifiers do not claim:
-// (1) that MD5 will do what you think it does;
-// (2) that this translation/ modification is accurate; or
+// (1) that MD5 will do what you think it does;
+// (2) that this translation/ modification is accurate; or
// (3) that this software is "merchantible."
//
// based on:
// is identified as the "RSA Data Security, Inc. MD5 Message-Digest
// Algorithm" in all material mentioning or referencing this software
// or this function.
-//
+//
// License is also granted to make and use derivative works provided
// that such works are identified as "derived from the RSA Data
// Security, Inc. MD5 Message-Digest Algorithm" in all material
// mentioning or referencing the derived work.
-//
+//
// RSA Data Security, Inc. makes no representations concerning either
// the merchantability of this software or the suitability of this
// software for any particular purpose. It is provided "as is"
// without express or implied warranty of any kind.
-//
+//
// These notices must be retained in any copies of any part of this
// documentation and/or software.
-//
+//
#include "addon/md5.hpp"
#include <stdexcept>
MD5::MD5() :
+ buffer(),
+ digest(),
finalized()
{
init();
}
void MD5::update(FILE *file) {
- uint8_t buffer[1024];
+ uint8_t buffer_[1024];
int len;
- while ((len=fread(buffer, 1, 1024, file))) update(buffer, len);
+ while ((len=fread(buffer_, 1, 1024, file))) update(buffer_, len);
fclose (file);
}
void MD5::update(std::istream& stream) {
- uint8_t buffer[1024];
- int len;
+ uint8_t buffer_[1024];
while (stream.good()) {
- stream.read((char*)buffer, 1024); // note that return value of read is unusable.
- len=stream.gcount();
- update(buffer, len);
+ stream.read((char*)buffer_, 1024); // note that return value of read is unusable.
+ int len = stream.gcount();
+ update(buffer_, len);
}
}
void MD5::update(std::ifstream& stream) {
- uint8_t buffer[1024];
- int len;
+ uint8_t buffer_[1024];
while (stream.good()) {
- stream.read((char*)buffer, 1024); // note that return value of read is unusable.
- len=stream.gcount();
- update(buffer, len);
+ stream.read((char*)buffer_, 1024); // note that return value of read is unusable.
+ int len = stream.gcount();
+ update(buffer_, len);
}
}
finalize ();
}
-MD5::MD5(std::istream& stream) :
+MD5::MD5(std::istream& stream) :
finalized()
{
init(); // must called by all constructors
s[32]='\0';
- return s;
+ // Create string from 's'
+ std::string s_str = std::string(s);
+ delete[] s;
+
+ return s_str;
}
std::ostream& operator<<(std::ostream &stream, MD5 context) {