add generic digest class

Change-Id: Ic5d2d8fbb0bb4edc4c966e185be81f6ca673950e
Reviewed-on: https://gerrit.libreoffice.org/36790
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
This commit is contained in:
Markus Mohrhard
2017-04-21 05:38:21 +02:00
parent 6c8fd43cd1
commit b7324ecbf3
3 changed files with 206 additions and 0 deletions

View File

@ -0,0 +1,47 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <comphelper/comphelperdllapi.h>
#include <memory>
#include <vector>
namespace comphelper {
enum class HashType
{
SHA1,
SHA256,
SHA512
};
struct HashImpl;
class COMPHELPER_DLLPUBLIC Hash
{
private:
std::unique_ptr<HashImpl> mpImpl;
public:
Hash(HashType eType);
~Hash();
void update(const unsigned char* pInput, size_t length);
std::vector<unsigned char> finalize();
static std::vector<unsigned char> calculateHash(const unsigned char* pInput, size_t length, HashType eType);
size_t getLength() const;
};
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */