TTKMusicPlayer  3.7.0.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 - 2024 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:
47 
51  QString encrypt(const QString &data, const QString &key);
55  QString decrypt(const QString &data, const QString &key);
56 
57 private:
61  TTKString xxteaEncrypt(const TTKString &data, const TTKString &key);
65  QString xxteaEncrypt(const QString &data, const QString &key);
66 
70  TTKString xxteaDecrypt(const TTKString &data, const TTKString &key);
74  QString xxteaDecrypt(const QString &data, const QString &key);
75 
79  uchar *doXxteaEncrypt(uchar *data, xxtea_uint len, uchar *key, xxtea_uint *retLength);
83  uchar *doXxteaDecrypt(uchar *data, xxtea_uint len, uchar *key, xxtea_uint *retLength);
87  void xxteaUintEncrypt(xxtea_uint *v, xxtea_uint len, xxtea_uint *k);
91  void xxteaUintDecrypt(xxtea_uint *v, xxtea_uint len, xxtea_uint *k);
95  uchar *fixKeyLength(uchar *key, xxtea_uint keyLength);
99  xxtea_uint *xxteaToUintArray(uchar *data, xxtea_uint len, int includeLength, xxtea_uint *retLength);
103  uchar *xxteaToByteArray(xxtea_uint *data, xxtea_uint len, int includeLength, xxtea_uint *retLength);
104 
108  uchar *xxteaEncrypt(uchar *data, xxtea_uint dataLength, uchar *key, xxtea_uint keyLength, xxtea_uint *retLengthgth);
112  uchar *xxteaDecrypt(uchar *data, xxtea_uint dataLength, uchar *key, xxtea_uint keyLength, xxtea_uint *retLengthgth);
113 
114 };
115 
116 #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:152