TTKMusicPlayer  4.1.3.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkcryptographichash.h
Go to the documentation of this file.
1 #ifndef TTKCRYPTOGRAPHICHASH_H
2 #define TTKCRYPTOGRAPHICHASH_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module project
6  * Copyright (C) 2015 - 2025 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include "ttkmoduleexport.h"
23 
24 #if defined(_MSC_VER)
25 using xxtea_uint = unsigned __int32;
26 # pragma warning(disable:4267)
27 #else
28 # if defined(__FreeBSD__) && __FreeBSD__ < 5
29 # include <inttypes.h>
30 # else
31 # include <stdint.h>
32 # endif
33 using xxtea_uint = uint32_t;
34 #endif
35 
40 {
42 public:
46  QString encrypt(const QString &data, const char *key);
50  QString decrypt(const QString &data, const char *key);
51 
52 private:
56  TTKString xxteaEncrypt(const TTKString &data, const char *key);
60  TTKString xxteaDecrypt(const TTKString &data, const char *key);
61 
65  uchar *doXxteaEncrypt(uchar *data, xxtea_uint len, uchar *key, xxtea_uint *retLength);
69  uchar *doXxteaDecrypt(uchar *data, xxtea_uint len, uchar *key, xxtea_uint *retLength);
73  void xxteaUintEncrypt(xxtea_uint *v, xxtea_uint len, xxtea_uint *k);
77  void xxteaUintDecrypt(xxtea_uint *v, xxtea_uint len, xxtea_uint *k);
81  uchar *fixKeyLength(uchar *key, xxtea_uint keyLength);
85  xxtea_uint *xxteaToUintArray(uchar *data, xxtea_uint len, int includeLength, xxtea_uint *retLength);
89  uchar *xxteaToByteArray(xxtea_uint *data, xxtea_uint len, int includeLength, xxtea_uint *retLength);
90 
94  uchar *xxteaEncrypt(uchar *data, xxtea_uint dataLength, uchar *key, xxtea_uint keyLength, xxtea_uint *retLengthgth);
98  uchar *xxteaDecrypt(uchar *data, xxtea_uint dataLength, uchar *key, xxtea_uint keyLength, xxtea_uint *retLengthgth);
99 
100 };
101 
102 #endif // TTKCRYPTOGRAPHICHASH_H
#define TTK_MODULE_EXPORT
uint32_t xxtea_uint
static constexpr wchar_t key[]
std::string TTKString
Definition: ttkglobal.h:121
The class of the string cryptographic hash.
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:168