Kylin/Encrypt/SecureHashAlgorithm.h
2024-06-19 23:16:48 +08:00

28 lines
719 B
C++

#ifndef SECUREHASHALGORITHM_H
#define SECUREHASHALGORITHM_H
#include <string>
#include <string_view>
#include <cstdint>
class SecureHashAlgorithmPrivate;
class SecureHashAlgorithm {
public:
using Sha256DigestType = uint8_t[32];
enum Type {
SHA256,
};
SecureHashAlgorithm();
~SecureHashAlgorithm();
int update(const unsigned char *input, size_t ilen);
int finish(unsigned char *output);
static int sha256(const unsigned char *input, size_t ilen, unsigned char *output);
static std::string sha256(const std::string_view &input, Sha256DigestType &digest);
private:
SecureHashAlgorithmPrivate *m_d{nullptr};
};
#endif // SECUREHASHALGORITHM_H