diff --git a/src/common/tvgCompressor.cpp b/src/common/tvgCompressor.cpp index 709cb22f..e7560e79 100644 --- a/src/common/tvgCompressor.cpp +++ b/src/common/tvgCompressor.cpp @@ -472,4 +472,19 @@ size_t b64Decode(const char* encoded, const size_t len, char** decoded) } +/************************************************************************/ +/* DJB2 Implementation */ +/************************************************************************/ + +unsigned long djb2Encode(const char* str) +{ + unsigned long hash = 5381; + int c; + + while ((c = *str++)) { + hash = ((hash << 5) + hash) + c; // hash * 33 + c + } + return hash; +} + } \ No newline at end of file diff --git a/src/common/tvgCompressor.h b/src/common/tvgCompressor.h index 0756127e..b043cc77 100644 --- a/src/common/tvgCompressor.h +++ b/src/common/tvgCompressor.h @@ -30,6 +30,7 @@ namespace tvg uint8_t* lzwEncode(const uint8_t* uncompressed, uint32_t uncompressedSizeBytes, uint32_t* compressedSizeBytes, uint32_t* compressedSizeBits); uint8_t* lzwDecode(const uint8_t* compressed, uint32_t compressedSizeBytes, uint32_t compressedSizeBits, uint32_t uncompressedSizeBytes); size_t b64Decode(const char* encoded, const size_t len, char** decoded); + unsigned long djb2Encode(const char* str); } #endif //_TVG_COMPRESSOR_H_