Skip to content

Commit 190b783

Browse files
authored
Revert "Fix #1443 - trim teaEncode trailing zeroes (#1534)" (#1619)
This reverts commit 767a41c.
1 parent 062aa3f commit 190b783

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

Shared/sdk/SharedUtil.Hash.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ namespace SharedUtil
8080
unsigned char m_digest[16];
8181
};
8282

83+
void encodeXtea(unsigned int* v, unsigned int* w, unsigned int* k);
84+
void decodeXTea(unsigned int* v, unsigned int* w, unsigned int* k);
85+
8386
void TeaEncode(const SString& str, const SString& key, SString* out);
8487
void TeaDecode(const SString& str, const SString& key, SString* out);
8588

Shared/sdk/SharedUtil.Hash.hpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ namespace SharedUtil
696696
return GenerateHashHexString(hashFunction, NULL, 0);
697697
}
698698

699-
inline void encodeXtea(unsigned int* v, unsigned int* w, unsigned int* k)
699+
void encodeXtea(unsigned int* v, unsigned int* w, unsigned int* k)
700700
{
701701
unsigned int v0 = v[0], v1 = v[1], i, sum = 0;
702702
unsigned int delta = 0x9E3779B9;
@@ -710,7 +710,7 @@ namespace SharedUtil
710710
w[1] = v1;
711711
}
712712

713-
inline void decodeXtea(unsigned int* v, unsigned int* w, unsigned int* k)
713+
void decodeXtea(unsigned int* v, unsigned int* w, unsigned int* k)
714714
{
715715
unsigned int v0 = v[0], v1 = v[1], i, sum = 0xC6EF3720;
716716
unsigned int delta = 0x9E3779B9;
@@ -818,26 +818,5 @@ namespace SharedUtil
818818

819819
out->assign((char*)buffer, numPasses * 4);
820820
delete[] buffer;
821-
822-
823-
// Delete all 0's from the end
824-
// As of now, even if the user passed it in
825-
// We'll delete it, because there's no way
826-
// We can know if the user added the padding or not.
827-
828-
// Note: If we get there, there's at least 1 block(4 chars)
829-
// before out->end()
830-
{
831-
// Traverse the string until the beginning, or until the fist non-0 char
832-
auto iter = out->end();
833-
for (; iter != out->begin(); iter--)
834-
{
835-
if (*std::prev(iter) != 0)
836-
break;
837-
}
838-
839-
if (iter != out->end())
840-
out->erase(iter, out->end()); // Erase all 0s
841-
}
842821
}
843822
} // namespace SharedUtil

0 commit comments

Comments
 (0)