X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=docs%2Fd2%2Fdad%2F_hash_8h_source.html;h=c766025561b79e641d7a66d820fb60f674a1c3b5;hb=ca093ae096bb3685afa157c42650a889166b2894;hp=e4e2d207cedef8a913190f8c370e4a05eb744c15;hpb=9b75396184a0f80c7eeb8702f5b05745832c1d2f;p=mutilities%2FMUtilities.git diff --git a/docs/d2/dad/_hash_8h_source.html b/docs/d2/dad/_hash_8h_source.html index e4e2d20..c766025 100644 --- a/docs/d2/dad/_hash_8h_source.html +++ b/docs/d2/dad/_hash_8h_source.html @@ -67,7 +67,7 @@ $(function() {
Hash.h
-Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
29 #pragma once
30 
31 //MUtils
32 #include <MUtils/Global.h>
33 
34 //Qt
35 #include <QByteArray>
36 #include <QFile>
37 
38 namespace MUtils
39 {
40  namespace Hash
41  {
42  static const quint16 HASH_BLAKE2_512 = 0x0000U;
43  static const quint16 HASH_KECCAK_224 = 0x0100U;
44  static const quint16 HASH_KECCAK_256 = 0x0101U;
45  static const quint16 HASH_KECCAK_384 = 0x0102U;
46  static const quint16 HASH_KECCAK_512 = 0x0103U;
47 
57  class MUTILS_API Hash
58  {
59  public:
60  virtual ~Hash(void) {};
61 
73  bool update(const quint8 *const data, const quint32 len) { return process(data, len); }
74 
84  bool update(const QByteArray &data) { return process(((const quint8*)data.constData()), ((quint32)data.length())); }
85 
95  bool update(QFile &file);
96 
106  QByteArray digest(const bool bAsHex = true) { return bAsHex ? finalize().toHex() : finalize(); }
107 
108  protected:
109  Hash(const char* key = NULL) {/*nothing to do*/};
110  virtual bool process(const quint8 *const data, const quint32 len) = 0;
111  virtual QByteArray finalize(void) = 0;
112 
113  private:
115  };
116 
128  MUTILS_API Hash *create(const quint16 &hashId, const char *const key = NULL);
129  }
130 }
bool update(const QByteArray &data)
Process the next chunk of input data.
Definition: Hash.h:84
+Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
29 #pragma once
30 
31 //MUtils
32 #include <MUtils/Global.h>
33 
34 //Qt
35 #include <QByteArray>
36 #include <QFile>
37 
38 namespace MUtils
39 {
40  namespace Hash
41  {
42  static const quint16 HASH_BLAKE2_512 = 0x0000U;
43  static const quint16 HASH_KECCAK_224 = 0x0100U;
44  static const quint16 HASH_KECCAK_256 = 0x0101U;
45  static const quint16 HASH_KECCAK_384 = 0x0102U;
46  static const quint16 HASH_KECCAK_512 = 0x0103U;
47 
57  class MUTILS_API Hash
58  {
59  public:
60  virtual ~Hash(void) {};
61 
73  bool update(const quint8 *const data, const quint32 len) { return process(data, len); }
74 
84  bool update(const QByteArray &data) { return process(((const quint8*)data.constData()), ((quint32)data.length())); }
85 
95  bool update(QFile &file);
96 
106  QByteArray digest(const bool bAsHex = true) { return bAsHex ? finalize().toHex() : finalize(); }
107 
108  protected:
109  Hash(const char* key = NULL) {/*nothing to do*/};
110  virtual bool process(const quint8 *const data, const quint32 len) = 0;
111  virtual QByteArray finalize(void) = 0;
112 
113  private:
115  };
116 
128  MUTILS_API Hash *create(const quint16 &hashId, const char *const key = NULL);
129  }
130 }
bool update(const QByteArray &data)
Process the next chunk of input data.
Definition: Hash.h:84
This file contains miscellaneous functions that are generally useful for Qt-based applications...
bool update(const quint8 *const data, const quint32 len)
Process the next chunk of input data.
Definition: Hash.h:73
static const quint16 HASH_BLAKE2_512
Hash algorithm identifier.
Definition: Hash.h:42