home *** CD-ROM | disk | FTP | other *** search
- (extracted from DEATH's email:)
- -----------------
-
- Well it's pretty hard to have a programme like that, that will also work with
- this specific cryptogram,
- since there are too few characters to do a statistical analysis (refer to LANAKI
- cryptogram lessons :) and single character statistical analysis was out of the
- question (transposition cipher).
-
- --------------------
-
- I already tried some rules so I thought, hey an english sentence can start with a
- parenthesis :)
-
- PPS: Hehe.. Serial: 5706498132
-
- ---------------------------------
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- char *permute( char *strng, int length);
-
- void crypt(char *src, char *passphrase, char *dst)
- {
- short count;
- short count2;
- short index;
-
- for (count = 0; count < 10; count++) {
- index = (passphrase[count] - '0') * 0x0E;
- for (count2 = 0; count2 < 0x0E; count2++) {
- dst[count2 * 10 + count] = src[index + count2];
- }
- }
- }
-
- void main(void)
- {
- char cryptogram[] = "r whlyeo l r.r nih\"h Lan ,idthy iru Dedforaeio
- renShLhe t k ttliy i he osiso\"saauet. ei ualsy lna ,i.rb foylhewmsolzosdaa
- eusIeHwd.aywaeuC\0xD\0xA\0xD$";
- char dest[512];
- char *passphrase = "0123456789";
- char dest2[512];
-
- memset(dest, 0, sizeof(dest));
- memset(dest2, 0, sizeof(dest));
-
- passphrase = permute(passphrase, 10);
-
- do {
- crypt(cryptogram, passphrase, dest);
- crypt(dest, passphrase, dest2);
- if (dest2[0] == '"' && dest2[139] == '.' && strstr(dest2, ", ") &&
- (strstr(dest2, " \"") == NULL)) {
- if (isupper(dest2[1])) {
- printf("%s\n", dest2);
- printf("%s\n\n", passphrase);
- }
- }
- } while (passphrase = permute(NULL, 10));
- }
-
- /* permute ( char *strng, int length) returns a pointer to a permuted */
- /* string, first call, call with string and origonal string is returned */
- /* each subsiquent call, call with NULL, returns one permutation */
- /* calls after all permuataions have been returned return NULL */
- /* ( always call with strlen(string) as length ) */
- /* will return NULL for errors */
- /* not very defensive ( ie WILL BREAK ) */
-
- /* dave chapman july '91 released to public domain */
-
- char *permute( char *strng, int length);
-
- char *permute( char *strng, int length)
- {
- char c;
- static int level;
- static char *str;
- static char *curr;
- static int *counts;
-
- if ( 0 >= length ) return NULL;
- if ( NULL != strng )
- {
- str = malloc( length+1 ); /* first call, copy string for use */
- counts = calloc( length, sizeof(int) ); /* where are we? */
-
- /* str = calloc( length+1, sizeof(int) + 1 ); and some manipulation
- lets the caller free this memory */
-
- strcpy( str, strng );
- curr = str;
- level = 0;
- return str;
- }
- if ( 2 == length )
- {
- c = *curr; /* rotate last 2 chars */
- *curr = *(curr+1);
- *(curr+1) = c;
- (*(counts+level))++; /* <- I thought *(counts+level)++ would inc */
- /* the counter, it didn't comment? */
- }
- else
- { /* go down one level */
- curr++;
- level++;
- if ( NULL == permute( NULL, length-1 ))
- {
- c = *(--curr); /* done lower levels, rotate this one */
- memmove( curr, curr+1, length-1 );
- *(curr + length-1) = c;
- (*(counts + --level))++;
- }
- else
- {
- --curr;
- --level;
- }
- }
- if ( *(counts+level) >= length )
- {
- *(counts+level) = 0; /* reset it */
- return NULL; /* done here */
- }
- return str; /* still some left */
- }
-
-
- ------------------
- Cya.. DEATH
-
-