--- src/filed/restore.c	Mon Oct  4 16:34:01 2004
+++ /home/dan/src/restore.c	Sun Nov 21 18:51:51 2004
@@ -29,6 +29,12 @@
 #include "bacula.h"
 #include "filed.h"
 
+#define ENCRYPT 1
+
+#ifdef ENCRYPT
+bool bdecrypt(Bytef *dest, uLong sourceLen);
+#endif
+
 #ifdef HAVE_ACL
 #include <sys/acl.h>
 #include <acl/libacl.h>
@@ -235,6 +241,10 @@
 	       wbuf = sd->msg;
 	       wsize = sd->msglen;
 	    }
+#ifdef ENCRYPT
+     /* decrypt the block */
+	 bdecrypt((Bytef *)sd->msg, sd->msglen);
+#endif
             Dmsg2(30, "Write %u bytes, total before write=%u\n", wsize, total);
 	    if ((uint32_t)bwrite(&bfd, wbuf, wsize) != wsize) {
                Dmsg0(0, "===Write error===\n");
@@ -286,6 +296,11 @@
 	       wbuf = sd->msg;
 	       wsize = sd->msglen;
 	    }
+
+#ifdef ENCRYPT
+     /* decrypt the block */
+	 bdecrypt((Bytef *)sd->msg, sd->msglen);
+#endif
 	    compress_len = compress_buf_size;
             Dmsg2(100, "Comp_len=%d msglen=%d\n", compress_len, wsize);
 	    if ((stat=uncompress((Byte *)jcr->compress_buf, &compress_len, 
@@ -434,5 +449,18 @@
    default:
       return "*none*";
    }
+}
+#endif
+
+
+#ifdef ENCRYPT
+bool bdecrypt(Bytef *dest, uLong sourceLen) {
+	Bytef *i;
+
+	for (i = dest; i < (dest + sourceLen); i++) {
+		*i = *i ^ 170;
+	}
+
+	return 1;
 }
 #endif

