1
0
forked from um/kgg-dec

fix #2: do not discard trailing zero in decrypted ekey.

This commit is contained in:
鲁树人 2024-11-19 17:02:02 +09:00
parent 2908525c5c
commit 74ba5156df

View File

@ -26,14 +26,8 @@ std::string_view span2ss(std::span<T> span) {
return std::string_view(reinterpret_cast<char*>(span.data()), span.size());
}
void remove_trailing_zeros(std::vector<uint8_t>& vec) {
auto it = std::find_if(vec.rbegin(), vec.rend(), [](uint8_t value) { return value != 0; });
vec.erase(it.base(), vec.end());
}
std::vector<uint8_t> decrypt_ekey_v1(std::string_view ekey) {
std::vector<uint8_t> result = b64_decode(reinterpret_cast<const uint8_t*>(ekey.data()), ekey.size());
remove_trailing_zeros(result);
uint32_t tea_key[4] = {
0x69005600 | static_cast<uint32_t>(result[0] << 16) | (result[1]),