@@ -93,25 +93,25 @@ namespace cms {
9393 " f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" ;
9494
9595 std::string MD5Result::toString () const {
96- char buf[ 16 * 2 ] ;
97- char * pBuf = buf;
98- for (unsigned int i = 0 ; i < sizeof ( bytes); ++i ) {
99- const char * p = s_hexValues + 2 * bytes[i] ;
96+ std::array< char , 16 * 2 > buf ;
97+ char * pBuf = buf. begin () ;
98+ for (auto b : bytes) {
99+ const char * p = s_hexValues + 2 * b ;
100100 *pBuf = *p;
101101 ++pBuf;
102102 ++p;
103103 *pBuf = *p;
104104 ++pBuf;
105105 }
106- return std::string (buf, sizeof ( buf));
106+ return std::string (buf. begin (), buf. end ( ));
107107 }
108108
109109 std::string MD5Result::compactForm () const {
110110 // This is somewhat dangerous, because the conversion of 'unsigned
111111 // char' to 'char' may be undefined if 'char' is a signed type
112112 // (4.7p3 in the Standard).
113- const char * p = reinterpret_cast <const char *>(& bytes[ 0 ] );
114- return std::string (p, p + sizeof ( bytes));
113+ const char * p = reinterpret_cast <const char *>(bytes. data () );
114+ return std::string (p, p + bytes. size ( ));
115115 }
116116
117117 void MD5Result::fromHexifiedString (std::string const & hexy) {
@@ -139,11 +139,11 @@ namespace cms {
139139 bool MD5Result::isValid () const { return (*this != invalidResult ()); }
140140
141141 bool operator ==(MD5Result const & a, MD5Result const & b) {
142- return std::equal (a.bytes , a.bytes + sizeof (a. bytes ), b.bytes );
142+ return std::equal (a.bytes . begin () , a.bytes . end ( ), b.bytes . begin () );
143143 }
144144
145145 bool operator <(MD5Result const & a, MD5Result const & b) {
146- return std::lexicographical_compare (a.bytes , a.bytes + sizeof (a. bytes ), b.bytes , b.bytes + sizeof (b. bytes ));
146+ return std::lexicographical_compare (a.bytes . begin () , a.bytes . end ( ), b.bytes . begin () , b.bytes . end ( ));
147147 }
148148
149149 // --------------------------------------------------------------------
@@ -170,7 +170,7 @@ namespace cms {
170170
171171 MD5Result Digest::digest () {
172172 MD5Result aDigest;
173- md5_finish (&state_, aDigest.bytes );
173+ md5_finish (&state_, aDigest.bytes . data () );
174174 return aDigest;
175175 }
176176} // namespace cms
0 commit comments