Same for the hasher.

This commit is contained in:
Relintai 2021-11-01 19:16:43 +01:00
parent c86ed59dd6
commit 3f190e9a53
3 changed files with 10 additions and 10 deletions

View File

@ -1,10 +1,10 @@
#include "hlib_sha256.h" #include "hlib_sha256.h"
std::string HashLibSHA256::compute(const void *data, size_t num_bytes) { String HashLibSHA256::compute(const void *data, size_t num_bytes) {
return hasher.operator()(data, num_bytes); return hasher.operator()(data, num_bytes);
} }
std::string HashLibSHA256::compute(const std::string &text) { String HashLibSHA256::compute(const String &text) {
return hasher.operator()(text); return hasher.operator()(text);
} }
@ -12,7 +12,7 @@ void HashLibSHA256::add(const void *data, size_t num_bytes) {
hasher.add(data, num_bytes); hasher.add(data, num_bytes);
} }
std::string HashLibSHA256::get_hash() { String HashLibSHA256::get_hash() {
return hasher.getHash(); return hasher.getHash();
} }

View File

@ -7,11 +7,11 @@
class HashLibSHA256 : public SHA256 { class HashLibSHA256 : public SHA256 {
public: public:
std::string compute(const void *data, size_t num_bytes); String compute(const void *data, size_t num_bytes);
std::string compute(const std::string &text); String compute(const String &text);
void add(const void *data, size_t num_bytes); void add(const void *data, size_t num_bytes);
std::string get_hash(); String get_hash();
void get_hash(unsigned char *buffer, size_t buffer_len); void get_hash(unsigned char *buffer, size_t buffer_len);
void reset(); void reset();

View File

@ -1,7 +1,7 @@
#ifndef SHA256_H #ifndef SHA256_H
#define SHA256_H #define SHA256_H
#include <string> #include "core/string.h"
#include "core/reference.h" #include "core/reference.h"
@ -9,11 +9,11 @@ class SHA256 : public Reference {
RCPP_OBJECT(SHA256, Reference); RCPP_OBJECT(SHA256, Reference);
public: public:
virtual std::string compute(const void *data, size_t num_bytes) = 0; virtual String compute(const void *data, size_t num_bytes) = 0;
virtual std::string compute(const std::string &text) = 0; virtual String compute(const String &text) = 0;
virtual void add(const void *data, size_t num_bytes) = 0; virtual void add(const void *data, size_t num_bytes) = 0;
virtual std::string get_hash() = 0; virtual String get_hash() = 0;
virtual void get_hash(unsigned char *buffer, size_t buffer_len) = 0; virtual void get_hash(unsigned char *buffer, size_t buffer_len) = 0;
virtual void reset() = 0; virtual void reset() = 0;