We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 52b6055 commit e967187Copy full SHA for e967187
src/md5.cpp
@@ -334,14 +334,16 @@ MD5& MD5::finalize()
334
// return hex representation of digest as string
335
std::string MD5::hexdigest() const
336
{
337
- if (!finalized)
+ if (!finalized) {
338
return "";
339
-
+ }
340
+ const std::string sHex = "0123456789abcdef";
341
char buf[33];
- for (int i=0; i<16; i++)
342
- sprintf(buf+i*2, "%02x", digest[i]);
+ for (int i = 0; i < 16; i++) {
343
+ buf[i*2] = sHex[digest[i] >> 4 & 0x0F];
344
+ buf[i*2+1] = sHex[digest[i] & 0x0F];
345
346
buf[32]=0;
347
return std::string(buf);
348
}
349
0 commit comments