#include "sha1.h"
#include <stddef.h>
+#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
sha1_process_bytes(data, len, &ctx);
}
+bool SHA1Checksum::process_file(const char *filename)
+{
+ FILE *f = fopen(filename, "rb");
+ if (f == NULL)
+ return false;
+
+ while (!feof(f)) {
+ char buf[4096];
+ size_t bytes = fread(buf, 1, sizeof(buf), f);
+
+ if (ferror(f)) {
+ fclose(f);
+ return false;
+ }
+
+ process(buf, bytes);
+ }
+
+ fclose(f);
+ return true;
+}
+
const uint8_t *SHA1Checksum::checksum()
{
sha1_finish_ctx(&ctx, resbuf);
{
uint8_t resbuf[20];
char hexbuf[4];
- string result = "sha-1:";
+ string result = "sha1=";
sha1_finish_ctx(&ctx, resbuf);