diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-04-21 05:38:21 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-04-21 22:43:54 +0200 |
commit | b7324ecbf36aae49627d5a5ff250a94de3abc4aa (patch) | |
tree | 94cb3e6ac31996431dbb25223c6c477b2a2e1ffd /include/comphelper | |
parent | [pt-PT] Autocorrect - Added 25 words (diff) | |
download | core-b7324ecbf36aae49627d5a5ff250a94de3abc4aa.tar.gz core-b7324ecbf36aae49627d5a5ff250a94de3abc4aa.zip |
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>
Diffstat (limited to 'include/comphelper')
-rw-r--r-- | include/comphelper/hash.hxx | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/include/comphelper/hash.hxx b/include/comphelper/hash.hxx new file mode 100644 index 000000000000..c14c6c748fee --- /dev/null +++ b/include/comphelper/hash.hxx @@ -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: */ |