diff options
author | danglassey <danglassey> | 2002-08-14 09:57:17 +0000 |
---|---|---|
committer | danglassey <danglassey> | 2002-08-14 09:57:17 +0000 |
commit | daa67ff1f728c07f2a116ee9a9f4505479ca6808 (patch) | |
tree | c224a537d30480002ae0560cc9104b543b4d1b5e /utilities/ciphertest.cpp | |
parent | 6d6973e035aac5ec1676efccd5b8ada70c40b639 (diff) | |
download | sword-sf-cvs-import-1.1.1.tar.gz |
Initial import from crosswire CVS for syncingimport-1.1.1
Diffstat (limited to 'utilities/ciphertest.cpp')
-rw-r--r-- | utilities/ciphertest.cpp | 55 |
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; +} |