aboutsummaryrefslogtreecommitdiffstats
path: root/utilities/ciphertest.cpp
diff options
context:
space:
mode:
authordanglassey <danglassey>2002-08-14 09:57:17 +0000
committerdanglassey <danglassey>2002-08-14 09:57:17 +0000
commitc9458897ebbb739d8db83c80e06512d8a612f743 (patch)
treef8c5381045887e34388cc6b26cfccc254bf766dc /utilities/ciphertest.cpp
downloadsword-sf-cvs-c9458897ebbb739d8db83c80e06512d8a612f743.tar.gz
*** empty log message ***
Diffstat (limited to 'utilities/ciphertest.cpp')
-rw-r--r--utilities/ciphertest.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/utilities/ciphertest.cpp b/utilities/ciphertest.cpp
new file mode 100644
index 0000000..b889324
--- /dev/null
+++ b/utilities/ciphertest.cpp
@@ -0,0 +1,55 @@
+#include <ctype.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#ifndef __GNUC__
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+#include <swcipher.h>
+#include <versekey.h>
+#include <rawverse.h>
+
+
+int main(int argc, char **argv) {
+ SWCipher *zobj;
+ VerseKey key;
+ RawVerse *rawdrv;
+ long offset;
+ unsigned short size;
+ unsigned int len;
+ char *tmpbuf;
+
+ if (argc != 3) {
+ fprintf(stderr, "usage: %s <datapath> \"<key>\"\n", argv[0]);
+ exit(1);
+ }
+
+ rawdrv = new RawVerse(argv[1]);
+ zobj = new SWCipher((unsigned char *)argv[2]);
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+
+ printf("\n");
+
+ key.AutoNormalize(0);
+ key.Headings(1);
+ for (key.Index(0); (!key.Error()); key++) {
+ rawdrv->findoffset(key.Testament(), key.Index(), &offset, &size);
+ tmpbuf = (char *) calloc(size + 2, 1);
+ rawdrv->readtext(key.Testament(), offset, size + 2, tmpbuf);
+ len = size;
+ zobj->cipherBuf(&len, tmpbuf);
+ printf("%s\n", zobj->Buf());
+ free(tmpbuf);
+ }
+ delete zobj;
+ return 0;
+}