blob: 21c55568cac0fe3c8419b8b6aeb3346241d79201 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2016 Ruslan Nigmatullin <euroelessar@yandex.ru>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtCore>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
//! [0]
QByteArray key = "key";
QByteArray message = "The quick brown fox jumps over the lazy dog";
//! [0]
//! [1]
QMessageAuthenticationCode code(QCryptographicHash::Sha256, key);
code.addData(message);
code.result().toHex(); // returns "f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8"
//! [1]
//! [2]
QMessageAuthenticationCode::hash(message, key, QCryptographicHash::Sha256).toHex();
//! [2]
}
|