mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 19:57:45 +00:00
Improve const in encryptGameArg
This commit is contained in:
parent
12c77d8130
commit
feb3961dd5
1 changed files with 9 additions and 8 deletions
|
@ -6,7 +6,7 @@
|
||||||
// from xivdev
|
// from xivdev
|
||||||
static char ChecksumTable[] = {'f', 'X', '1', 'p', 'G', 't', 'd', 'S', '5', 'C', 'A', 'P', '4', '_', 'V', 'L'};
|
static char ChecksumTable[] = {'f', 'X', '1', 'p', 'G', 't', 'd', 'S', '5', 'C', 'A', 'P', '4', '_', 'V', 'L'};
|
||||||
|
|
||||||
inline char GetChecksum(unsigned int key) {
|
inline char GetChecksum(const unsigned int key) {
|
||||||
auto value = key & 0x000F0000;
|
auto value = key & 0x000F0000;
|
||||||
return ChecksumTable[value >> 16];
|
return ChecksumTable[value >> 16];
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@ inline char GetChecksum(unsigned int key) {
|
||||||
uint32_t TickCount();
|
uint32_t TickCount();
|
||||||
|
|
||||||
inline QString encryptGameArg(const QString& arg) {
|
inline QString encryptGameArg(const QString& arg) {
|
||||||
unsigned int rawTicks = TickCount();
|
const uint32_t rawTicks = TickCount();
|
||||||
unsigned int ticks = rawTicks & 0xFFFFFFFFu;
|
const uint32_t ticks = rawTicks & 0xFFFFFFFFu;
|
||||||
unsigned int key = ticks & 0xFFFF0000u;
|
const uint32_t key = ticks & 0xFFFF0000u;
|
||||||
|
|
||||||
char buffer[9] = {};
|
char buffer[9]{};
|
||||||
sprintf(buffer, "%08x", key);
|
sprintf(buffer, "%08x", key);
|
||||||
|
|
||||||
Blowfish const* blowfish = physis_blowfish_initialize(reinterpret_cast<uint8_t*>(buffer), 9);
|
Blowfish const* blowfish = physis_blowfish_initialize(reinterpret_cast<uint8_t*>(buffer), 9);
|
||||||
|
@ -31,11 +31,12 @@ inline QString encryptGameArg(const QString& arg) {
|
||||||
physis_blowfish_encrypt(
|
physis_blowfish_encrypt(
|
||||||
blowfish, reinterpret_cast<uint8_t*>(toEncrypt.data()), toEncrypt.size(), &out_data, &out_size);
|
blowfish, reinterpret_cast<uint8_t*>(toEncrypt.data()), toEncrypt.size(), &out_data, &out_size);
|
||||||
|
|
||||||
QByteArray encryptedArg = QByteArray::fromRawData(reinterpret_cast<const char*>(out_data), out_size);
|
const QByteArray encryptedArg =
|
||||||
|
QByteArray::fromRawData(reinterpret_cast<const char*>(out_data), static_cast<int>(out_size));
|
||||||
|
|
||||||
QString base64 = encryptedArg.toBase64(
|
const QString base64 = encryptedArg.toBase64(
|
||||||
QByteArray::Base64Option::Base64UrlEncoding | QByteArray::Base64Option::KeepTrailingEquals);
|
QByteArray::Base64Option::Base64UrlEncoding | QByteArray::Base64Option::KeepTrailingEquals);
|
||||||
char checksum = GetChecksum(key);
|
const char checksum = GetChecksum(key);
|
||||||
|
|
||||||
return QString("//**sqex0003%1%2**//").arg(base64, QString(checksum));
|
return QString("//**sqex0003%1%2**//").arg(base64, QString(checksum));
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue