My Project
NPLCodec.h
1 #pragma once
2 
3 namespace NPL
4 {
5 #define NPL_PRIVATE_KEY_SIZE 64
6 
14  class NPLCodec
15  {
16  public:
25  static int Encode(char* dest, const char* src, int nSrcSize, uint32 nPublicKey = 0);
26 
35  static int Decode(char* dest, const char* src, int nSrcSize, uint32 nPublicKey = 0);
36 
42  static void UsePlainTextEncoding(bool bUsePlainTextEncoding);
43 
51  static void SetGenericKey(const byte* sKey, int nSize);
52 
65  static int Compress(string& outstring, const char* src, int nSrcSize, int compressionlevel = -1);
66 
73  static int Decompress(string& outstring, const char* src, int nSrcSize);
74  private:
75  static byte m_sPrivateKey[NPL_PRIVATE_KEY_SIZE+4];
76  };
77 }
define this to enable debugging of NPL code in visual studio
Definition: INPL.h:9
transport layer NPL message compressor(encoder) and decompresser(decoder) Currently, we use a very simply custom encoding/decoding algorithm.
Definition: NPLCodec.h:14
static int Decompress(string &outstring, const char *src, int nSrcSize)
Decompress src to destination.
Definition: NPLCodec.cpp:151
static int Encode(char *dest, const char *src, int nSrcSize, uint32 nPublicKey=0)
encode a byte array from src to dest
Definition: NPLCodec.cpp:45
static int Decode(char *dest, const char *src, int nSrcSize, uint32 nPublicKey=0)
decode a byte array from src to dest
Definition: NPLCodec.cpp:29
static void SetGenericKey(const byte *sKey, int nSize)
set the generic key that is used for encoding/decoding.
Definition: NPLCodec.cpp:89
static int Compress(string &outstring, const char *src, int nSrcSize, int compressionlevel=-1)
Compress src to a string buffer using zlib.
Definition: NPLCodec.cpp:111
static void UsePlainTextEncoding(bool bUsePlainTextEncoding)
no matter what public key is used, we will ensure that the encoded message is plain text [0...
Definition: NPLCodec.cpp:61