LibreOffice Module comphelper (master)  1
hash.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_COMPHELPER_HASH_HXX
11 #define INCLUDED_COMPHELPER_HASH_HXX
12 
14 
15 #include <memory>
16 #include <vector>
17 
18 namespace rtl {
19  class OUString;
20 }
21 
22 namespace comphelper {
23 
24 enum class HashType
25 {
26  MD5,
27  SHA1,
28  SHA256,
29  SHA512
30 };
31 
32 struct HashImpl;
33 
35 {
36 private:
37  std::unique_ptr<HashImpl> mpImpl;
38 
39 public:
40 
41  enum class IterCount
42  {
43  NONE,
44  PREPEND,
45  APPEND
46  };
47 
48  Hash(HashType eType);
49  ~Hash();
50 
51  void update(const unsigned char* pInput, size_t length);
52 
53  std::vector<unsigned char> finalize();
54 
55  static std::vector<unsigned char> calculateHash(const unsigned char* pInput, size_t length, HashType eType);
56 
86  static std::vector<unsigned char> calculateHash(
87  const unsigned char* pInput, size_t nLength,
88  const unsigned char* pSalt, size_t nSaltLen,
89  sal_uInt32 nSpinCount,
90  IterCount eIterCount,
91  HashType eType);
92 
101  static std::vector<unsigned char> calculateHash(
102  const rtl::OUString& rPassword,
103  const std::vector<unsigned char>& rSaltValue,
104  sal_uInt32 nSpinCount,
105  IterCount eIterCount,
106  HashType eType);
107 
108  size_t getLength() const;
109 };
110 
111 }
112 
113 #endif // INCLUDED_COMPHELPER_HASH_HXX
114 
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< HashImpl > mpImpl
Definition: hash.hxx:37
bool update()
Status finalize()
NONE
APPEND
double getLength(const B2DPolygon &rCandidate)
#define COMPHELPER_DLLPUBLIC