TTKMusicPlayer  4.3.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 - 2026 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 {
41 public:
45  QString encrypt(const QString &data, const char *key);
49  QString decrypt(const QString &data, const char *key);
50 
51 private:
55  TTKString xxteaEncrypt(const TTKString &data, const char *key);
59  TTKString xxteaDecrypt(const TTKString &data, const char *key);
60 
64  uchar* doXxteaEncrypt(uchar *data, xxtea_uint len, uchar *key, xxtea_uint *retLength);
68  uchar* doXxteaDecrypt(uchar *data, xxtea_uint len, uchar *key, xxtea_uint *retLength);
72  void xxteaUintEncrypt(xxtea_uint *v, xxtea_uint len, xxtea_uint *k);
76  void xxteaUintDecrypt(xxtea_uint *v, xxtea_uint len, xxtea_uint *k);
80  uchar* fixKeyLength(uchar *key, xxtea_uint keyLength);
84  xxtea_uint* xxteaToUintArray(uchar *data, xxtea_uint len, int includeLength, xxtea_uint *retLength);
88  uchar* xxteaToByteArray(xxtea_uint *data, xxtea_uint len, int includeLength, xxtea_uint *retLength);
89 
93  uchar* xxteaEncrypt(uchar *data, xxtea_uint dataLength, uchar *key, xxtea_uint keyLength, xxtea_uint *retLengthgth);
97  uchar* xxteaDecrypt(uchar *data, xxtea_uint dataLength, uchar *key, xxtea_uint keyLength, xxtea_uint *retLengthgth);
98 
99 };
100 
101 
105 namespace TTK
106 {
110  TTK_MODULE_EXPORT TTKString base64Encode(const unsigned char *bytes, unsigned int len);
115 
116 }
117 
118 #endif // TTKCRYPTOGRAPHICHASH_H
#define TTK_MODULE_EXPORT
uint32_t xxtea_uint
std::string TTKString
Definition: ttkglobal.h:168
The namespace of the application object.
Definition: ttkcompat.h:24
static constexpr wchar_t key[]
The class of the string cryptographic hash.
TTK_MODULE_EXPORT TTKString base64Decode(const TTKString &bytes)
TTK_MODULE_EXPORT TTKString base64Encode(const unsigned char *bytes, unsigned int len)