13 keylen(_keylen), keyoff(0)
15 key =
new unsigned char[keylen];
16 memcpy(key, _key, keylen);
20WvXOREncoder::~WvXOREncoder()
31 const unsigned char *data = inbuf.
get(len);
32 unsigned char *out = outbuf.
alloc(len);
37 *out++ = (*data++) ^ key[keyoff++];
46WvXORStream::WvXORStream(
WvStream *_cloned,
47 const void *_key,
size_t _keysize) :
50 readchain.append(
new WvXOREncoder(_key, _keysize),
true);
51 writechain.append(
new WvXOREncoder(_key, _keysize),
true);
size_t optgettable() const
Returns the optimal maximum number of elements in the buffer currently available for reading without ...
const T * get(size_t count)
Reads exactly the specified number of elements and returns a pointer to a storage location owned by t...
T * alloc(size_t count)
Allocates exactly the specified number of elements and returns a pointer to an UNINITIALIZED storage ...
WvEncoderStream chains a series of encoders on the input and output ports of the underlying stream to...
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
WvXOREncoder(const void *_key, size_t _keylen)
Creates a new XOR encoder / decoder.