Cuberite
A lightweight, fast and extensible game server for Minecraft
Sha1Checksum.h
Go to the documentation of this file.
1 
2 // Sha1Checksum.h
3 
4 // Declares the cSha1Checksum class representing the SHA-1 checksum calculator
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "mbedtls/sha1.h"
13 
14 
15 
16 
17 
20 {
21 public:
22  typedef Byte Checksum[20]; // The type used for storing the checksum
23 
24  cSha1Checksum(void);
25 
27  void Update(const Byte * a_Data, size_t a_Length);
28 
30  void Finalize(Checksum & a_Output);
31 
33  bool DoesAcceptInput(void) const { return m_DoesAcceptInput; }
34 
36  static void DigestToHex(const Checksum & a_Digest, AString & a_Out);
37 
41  static void DigestToJava(const Checksum & a_Digest, AString & a_Out);
42 
44  void Restart(void);
45 
46 protected:
49 
50  mbedtls_sha1_context m_Sha1;
51 } ;
52 
53 
54 
55 
unsigned char Byte
Definition: Globals.h:161
std::string AString
Definition: StringUtils.h:11
Calculates a SHA1 checksum for data stream.
Definition: Sha1Checksum.h:20
mbedtls_sha1_context m_Sha1
Definition: Sha1Checksum.h:50
void Update(const Byte *a_Data, size_t a_Length)
Adds the specified data to the checksum.
void Restart(void)
Clears the current context and start a new checksum calculation.
Byte Checksum[20]
Definition: Sha1Checksum.h:22
void Finalize(Checksum &a_Output)
Calculates and returns the final checksum.
bool DoesAcceptInput(void) const
Returns true if the object is accepts more input data, false if Finalize()-d (need to Restart())
Definition: Sha1Checksum.h:33
bool m_DoesAcceptInput
True if the object is accepts more input data, false if Finalize()-d (need to Restart())
Definition: Sha1Checksum.h:48
static void DigestToHex(const Checksum &a_Digest, AString &a_Out)
Converts a SHA1 digest into hex.
static void DigestToJava(const Checksum &a_Digest, AString &a_Out)
Converts a raw 160-bit SHA1 digest into a Java Hex representation According to http://wiki....