aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/filters/cipherfil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/filters/cipherfil.cpp')
-rw-r--r--src/modules/filters/cipherfil.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/modules/filters/cipherfil.cpp b/src/modules/filters/cipherfil.cpp
index ad55396..ddb97b1 100644
--- a/src/modules/filters/cipherfil.cpp
+++ b/src/modules/filters/cipherfil.cpp
@@ -28,11 +28,17 @@ char CipherFilter::ProcessText(char *text, int maxlen, const SWKey *key, const S
unsigned int len;
// len = strlen(text);
len = maxlen;
- if (len > 0) {
- cipher->cipherBuf(&len, text);
- strncpy(text, cipher->Buf(), (len < (unsigned int)maxlen) ? len : maxlen);
- }
- text[maxlen] = 0;
- text[maxlen+1] = 0;
+ if (len > 0) {
+ if (!key) { // hack, using key to determine encipher, or decipher
+ cipher->cipherBuf(&len, text);
+ memcpy(text, cipher->Buf(), (len < (unsigned int)(maxlen)) ? len : maxlen);
+ }
+ else if ((unsigned long)key == 1) {
+ cipher->Buf(text, len);
+ cipher->cipherBuf(&len);
+ memcpy(text, cipher->cipherBuf(&len), (len < (unsigned int)(maxlen)) ? len : maxlen);
+ }
+ }
+// text[maxlen] = 0;
return 0;
}