#include <string.h>
#include <arpa/inet.h>
+#include <string.h>
+
+using std::string;
+
/* SWAP does an endian swap on architectures that are little-endian,
as SHA1 needs some data in a big-endian form. */
#define SWAP(n) htonl(n)
sha1_finish_ctx(&ctx, resbuf);
return (const uint8_t *)resbuf;
}
+
+string SHA1Checksum::checksum_str()
+{
+ uint8_t resbuf[20];
+ char hexbuf[4];
+ string result = "sha1=";
+
+ sha1_finish_ctx(&ctx, resbuf);
+
+ for (int i = 0; i < 20; i++) {
+ sprintf(hexbuf, "%02x", resbuf[i]);
+ result += hexbuf;
+ }
+
+ return result;
+}