2
* Copyright 2013 Canonical Ltd.
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of version 3 of the GNU Lesser General Public
6
* License as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public
14
* License along with this library; if not, write to the
15
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
* Boston, MA 02110-1301, USA.
19
#include "./hash_algorithm.h"
21
QCryptographicHash::Algorithm
22
HashAlgorithm::getHashAlgo(const QString& algorithm) {
23
// lowercase the algorithm just in case
24
QString algoLower = algorithm.toLower();
25
QCryptographicHash::Algorithm algo = QCryptographicHash::Md5;
27
if (algoLower == "md5")
28
algo = QCryptographicHash::Md5;
29
else if (algoLower == "sha1")
30
algo = QCryptographicHash::Sha1;
31
else if (algoLower == "sha224")
32
algo = QCryptographicHash::Sha224;
33
else if (algoLower == "sha256")
34
algo = QCryptographicHash::Sha256;
35
else if (algoLower == "sha384")
36
algo = QCryptographicHash::Sha384;
37
else if (algoLower == "sha512")
38
algo = QCryptographicHash::Sha512;
40
algo = QCryptographicHash::Md5;
45
HashAlgorithm::getHashAlgo(QCryptographicHash::Algorithm algorithm) {
47
case QCryptographicHash::Md5:
49
case QCryptographicHash::Sha1:
51
case QCryptographicHash::Sha224:
53
case QCryptographicHash::Sha256:
55
case QCryptographicHash::Sha384:
57
case QCryptographicHash::Sha512: