The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CipherFilter Class Reference

#include <cipherfil.h>

+ Inheritance diagram for CipherFilter:
+ Collaboration diagram for CipherFilter:

Public Member Functions

 CipherFilter (const char *key)
 
virtual SWCiphergetCipher ()
 
virtual const char * getHeader () const
 
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *=0)
 
virtual ~CipherFilter ()
 

Private Attributes

SWCiphercipher
 

Detailed Description

Definition at line 34 of file cipherfil.h.

Constructor & Destructor Documentation

SWORD_NAMESPACE_START CipherFilter::CipherFilter ( const char *  key)

Definition at line 34 of file cipherfil.cpp.

34  {
35  cipher = new SWCipher((unsigned char *)key);
36 }
SWCipher * cipher
Definition: cipherfil.h:35
CipherFilter::~CipherFilter ( )
virtual

Definition at line 39 of file cipherfil.cpp.

39  {
40  delete cipher;
41 }
SWCipher * cipher
Definition: cipherfil.h:35

Member Function Documentation

SWCipher * CipherFilter::getCipher ( )
virtual

Definition at line 44 of file cipherfil.cpp.

44  {
45  return cipher;
46 }
SWCipher * cipher
Definition: cipherfil.h:35
virtual const char* SWFilter::getHeader ( ) const
inlinevirtualinherited

This method can supply a header associated with the processing done with this filter. A typical example is a suggested CSS style block for classed containers.

Reimplemented in OSISLaTeX, OSISXHTML, ThMLLaTeX, ThMLXHTML, TEIXHTML, GBFLaTeX, and GBFXHTML.

Definition at line 62 of file swfilter.h.

62 { return ""; }
char CipherFilter::processText ( SWBuf text,
const SWKey key = 0,
const SWModule module = 0 
)
virtual

This method processes and appropriately modifies the text given it for a particular filter task

Parameters
textThe text to be filtered/converted
keyCurrent key That was used.
moduleCurrent module.
Returns
0

Implements SWFilter.

Definition at line 49 of file cipherfil.cpp.

49  {
50  if (text.length() > 2) { //check if it's large enough to substract 2 in the next step.
51  unsigned long len = text.length();
52  if (!key) { // hack, using key to determine encipher, or decipher
53  cipher->setCipheredBuf(&len, text.getRawData()); //set buffer to enciphered text
55  // don't just assign text because we might be compressing binary data
56  text.setSize(len + 5);
57  memcpy(text.getRawData(), cipher->getUncipheredBuf(), len);
58  }
59  else if ((unsigned long)key == 1) {
60  cipher->setUncipheredBuf(text.getRawData(), len);
61  cipher->getCipheredBuf(&len);
62  text.setSize(len + 5);
63  memcpy(text.getRawData(), cipher->getCipheredBuf(&len), len);
64  }
65  }
66  return 0;
67 }
SWCipher * cipher
Definition: cipherfil.h:35
unsigned long length() const
Definition: swbuf.h:197
virtual void setCipheredBuf(unsigned long *len, const char *buf=0)
Definition: swcipher.cpp:95
char * getRawData()
Definition: swbuf.h:379
virtual char * getCipheredBuf(unsigned long *len=0)
Definition: swcipher.cpp:112
virtual void setUncipheredBuf(const char *buf=0, unsigned long len=0)
Definition: swcipher.cpp:67
virtual char * getUncipheredBuf()
Definition: swcipher.cpp:87
void setSize(unsigned long len)
Definition: swbuf.h:255

Member Data Documentation

SWCipher* CipherFilter::cipher
private

Definition at line 35 of file cipherfil.h.


The documentation for this class was generated from the following files: