You are here: minimalblue/ projects/
parent page print page bookmark page

charemap

Charemap is a little program to play with substitution ciphers. It's able to remap text, perform characters and word analysis and to automatically decrypt ciphertext.

Download:

Requirements

Glib, GNU make and a C compiler.

Installation

In order to compile charemap, simply type `make'. No installation required.

Running charemap

See ./charemap -h

Usage: charemap [options]...
Options:
  -h              This help.
  -v              Print version.
  -d              Decrypt the file.
                  Warning, this algorithm works ONLY on alphabetic lowercase characters.
                  Remap ciphertext with charemap before using this option.
  -s              Show only character occurrences and mapping.
  -c              Case sensitive.
  -a              Remap alpha characters only (preserves dots, blanks and so on...).
  -p              Print substituted text.
  -b              Show bigrams.
  -t              Show trigrams.
  -w              Show words.
  -m <file>       Use a sample file to generate digram statistics (default samples/moby.txt).
  -i <file>       Input file to parse.
  -o <file>       Output file with remapped characters.
  -l <file>       Remap using the typical character frequency of selected language (default: languages/en.txt).

Example

Here is an example of automatic decryption with a ciphertext shipped with charemap.

ciphertext:

SG PW, GH VGS SG PW: SKLS YI SKW AOWISYGV:
CKWSKWH 'SYI VGPZWH YV SKW MYVR SG IOFFWH
SKW IZYVNI LVR LHHGCI GF GOSHLNWGOI FGHSOVW,
GH SG SLXW L LHMI LNLYVIS L IWL GF SHGOPZWI,
LVR PU GBBGIYVN WVR SKWM. SG RYW: SG IZWWB;
VG MGHW; LVR PU L IZWWB SG ILU CW WVR
SKW KWLHSLJKW, LVR SKW SKGOILVR VLSOHLZ IKGJXI
SKLS FZWIK YI KWYH SG.

Decryption:

./charemap -i ciphers/tobeornot.txt -d -m samples/dorian.txt 

Decripting using bigram and trigram detection...
done!

The mapping found is:

    <- etaoihnsrdlumwyfcgpbvkxqjz
       ||||||||||||||||||||||||||
    -> jzfusrgtkxapyeilwomdnhbqcv

Decryption result:

to me, or not to me: that is the fuestion:
whether 'tis nomver in the yink to suller
the svings ank arrows ol outrageous lortune,
or to tabe a arys against a sea ol troumves,
ank mp oddosing enk they. to kie: to sveed;
no yore; ank mp a sveed to sap we enk
the heartache, ank the thousank naturav shocbs
that lvesh is heir to.

Affining result with dictionary-based decryption...
done!

The mapping found is:

    <- etaoihnsrdlumwyfcgpbvkxqjz
       ||||||||||||||||||||||||||
    -> jzqusrgtdxaymeifwobpnhkvcl

Decryption result:

to be, or not to be: that is the question:
whether 'tis nobler in the mind to suffer
the slings and arrows of outrageous fortune,
or to take a arms against a sea of troubles,
and by opposing end them. to die: to sleep;
no more; and by a sleep to say we end
the heartache, and the thousand natural shocks
that flesh is heir to.
last edit: 2010/01/20