56 m_DoesAcceptInput(true)
58 mbedtls_sha1_starts(&
m_Sha1);
69 mbedtls_sha1_update(&
m_Sha1, a_Data, a_Length);
80 mbedtls_sha1_finish(&
m_Sha1, a_Output);
91 memcpy(Digest, a_Digest,
sizeof(Digest));
93 bool IsNegative = (Digest[0] >= 0x80);
98 for (
int i = 19; i >= 0; i--)
100 Digest[i] = ~Digest[i];
103 carry = (Digest[i] == 0xff);
110 for (
int i = 0; i < 20; i++)
114 while ((a_Out.length() > 0) && (a_Out[0] ==
'0'))
120 a_Out.insert(0,
"-");
130 mbedtls_sha1_starts(&
m_Sha1);
void Finalize(Checksum &a_Output)
Calculates and returns the final checksum.
void Update(const Byte *a_Data, size_t a_Length)
Adds the specified data to the checksum.
AString & AppendPrintf(AString &a_Dst, const char *format, const Args &...args)
Add the formated string to the existing data in the string.
mbedtls_sha1_context m_Sha1
bool m_DoesAcceptInput
True if the object is accepts more input data, false if Finalize()-d (need to Restart()) ...
static void DigestToJava(const Checksum &a_Digest, AString &a_JavaOut)
Converts a raw 160-bit SHA1 digest into a Java Hex representation According to http://wiki.vg/Protocol_Encryption.
void Restart(void)
Clears the current context and start a new checksum calculation.