MD5Sum.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (C) 2014 by Ralf Kaestner                                        *
00003  * ralf.kaestner@gmail.com                                                    *
00004  *                                                                            *
00005  * This program is free software; you can redistribute it and/or modify       *
00006  * it under the terms of the Lesser GNU General Public License as published by*
00007  * the Free Software Foundation; either version 3 of the License, or          *
00008  * (at your option) any later version.                                        *
00009  *                                                                            *
00010  * This program is distributed in the hope that it will be useful,            *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               *
00013  * Lesser GNU General Public License for more details.                        *
00014  *                                                                            *
00015  * You should have received a copy of the Lesser GNU General Public License   *
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.       *
00017  ******************************************************************************/
00018 
00023 #ifndef VARIANT_TOPIC_TOOLS_MD5_SUM_H
00024 #define VARIANT_TOPIC_TOOLS_MD5_SUM_H
00025 
00026 #include <boost/array.hpp>
00027 
00028 #include <ros/ros.h>
00029 
00030 namespace variant_topic_tools {
00036   class MD5Sum {
00037   public:
00040     typedef boost::array<uint32_t, 4> Digest;
00041     
00044     MD5Sum(const std::string& text = std::string());
00045     
00048     MD5Sum(const MD5Sum& src);
00049     
00052     ~MD5Sum();
00053 
00056     size_t getNumDigestedBits() const;
00057     
00060     Digest getDigest() const;
00061     
00064     void update(const std::string& text);
00065     
00068     void clear();
00069     
00072     void write(std::ostream& stream) const;
00073     
00076     std::string toString() const;
00077     
00080     MD5Sum& operator<<(const std::string& text);
00081     
00082   protected:
00085     typedef boost::array<uint32_t, 2> Size;
00086     
00089     typedef boost::array<uint32_t, 16> Block;
00090     
00093     static const Digest initialDigest;
00094     
00098     static const boost::array<uint32_t, 64> numBitRotations;
00099     
00102     static const boost::array<uint32_t, 64> constants;
00103     
00106     static const Block padding;
00107     
00110     Digest digest;
00111 
00114     Size numDigestedBits;
00115     
00118     Block buffer;
00119     
00122     void update(const uint8_t* bytes, size_t numBytes);
00123         
00126     static void transform(const Block& block, Digest& digest);
00127     
00130     static uint32_t rotateLeft(uint32_t value, size_t numBits);
00131     
00134     static void update(Digest& digest, Size& numDigestedBits, Block& buffer,
00135       const uint8_t* bytes, size_t numBytes);
00136     
00139     static void finalize(Digest& digest, Size& numDigestedBits, Block& buffer);
00140   };
00141     
00144   std::ostream& operator<<(std::ostream& stream, const MD5Sum& md5Sum);
00145 };
00146 
00147 #endif


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Tue Jul 9 2019 03:18:42