// CryptBytes.h #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #ifndef CryptBytesh #define CryptBytesh #include "LZW.h" #include "RC6.h" #include "Base64.h" #include "URL.h" // Compresses and Encrypts a string of Bytes and Encodes them for use as URL Parameters (for passing on the WWW). class __declspec(novtable) CryptBytes { CryptBytes() {} // Private Constructor: you shouldn't create one of these. public: static void EncryptBytes(CBytes& Bytes, const char* Key) { LZW::Encode(Bytes); // Bytes1 is possibly now the LZW Compressed Binary Data CRC6(Key, Bytes); // This encrypts Bytes1 using default RC6 settings. The length of S increases by upto 16 Bytes (unless S is an empty string) - the last Byte is 0xE6 to indicate encrypted data. Base64::Encode(Bytes, false); URL::EncodeParameters(Bytes); // Uses null terminator } static void DecryptBytes(CBytes& Bytes, const char* Key) { URL::Decode(Bytes); Base64::Decode(Bytes, false); CRC6(Key, Bytes); // This decrypts Bytes2 using default RC6 settings. The length of S decreases by upto 16 Bytes (unless S is an empty string). LZW::Decode(Bytes); Bytes.SetNullTerminated(); } }; #endif // CryptBytesh