krypto [file] (Unix version)
jkrypto [file] (Java version)
jkrypto has a slightly different set of commands
jkrypto -g [file]
Transposition Ciphers form the second basic building block of ciphers. The core idea is to rearrange the order of basic units (letters/bytes/bits) without altering their actual values.
Works by spacing adjacent letters of the message at intervals down the strip of paper.
Plain: I CAME I SAW I CONQUERED Cipher: DEREU QNOCI WASIE MACI
Plain: I A E S W C N U R D
C M I A I O Q E E
Cipher: IAESW CNURD CMIAI OQEE
Sinkov, Fig 20, p143
All of the above are examples of how we can rearrange our basic units, here letters. Each has a rule saying how this is done, with the key specifying the particular variant of the rules used.
Plain: THESIMPLESTPOSSIBLETRANSPOSITIONSXX
Key (R): 2 5 4 1 3
Key (W): 4 1 5 3 2
T H E S I S T I E H
M P L E S E M S L P
T P O S S S T S O P
I B L E T E I T L B
R A N S P S R P N A
O S I T I T O I I S
O N S X X X O X S N
Cipher: STIEH EMSLP STSOP EITLB SRPNA TOIIS XOXSN
Example - Davies p26 Fig 2.14
Note that the Krypto program and Sinkov use different conventions as to what sort of key is used (read off vs write in), so take care not to be confused. Specifically note that krypto uses a read-off key.
Plain: ACONVENIENTWAYTOEXPRESSTHEPERMUTATION
Key (W): C O M P U T E R
Key (W): 1 4 3 5 8 7 2 6
A N O V I N C E
E W T A O T N Y
E R P E T S X S
H E P R T U E M
A O I N Z Z T Z
Cipher: ANOVI NCEEW TAOTN YERPE TSXSH EPRTU EMAOI NZZTZ
Example - Davies p26 Fig 2.15
Key(R): sorcery => 6 3 4 1 2 5 7 laser beams can be modulated to carry more intelligence than radio waves ==> erasb lecam snabd umole atoed ctamo ryrre elntl iicee ntgha dnria oesav w
LDWOE HETTS HESTR HUTEL OSBED EFIEV NT
2: LD WO EH ET TS HE ST RH UT EL OS BE DE FI EV NT - NO
3: LDW OEH ETT SHE STR HUT ELO SBE DEF IEV NT - NO
4: LDWO EHET TSHE STRH UTEL OSBE DEFI EVNT - NO
5: LDWOE HETTS HESTR HUTEL OSBED EFIEV NT - NO
6: LDWOEH ETTSHE STRHUT ELOSBE DEFIEV NT - YES!!!
WEHOLD THESET RUTHST OBESEL FEVIDE NT or
WE HOLD THESE TRUTHS TO BE SELF EVIDENT
For each possible length have to try all ways of permuting that sized block,
to see if we can recover English text. For 2 there's just 1 possibiity
DL OW clearly wrong. For 3 clear that LDW
cannot make a word. For 4 have 16 ways, but none work. For 5 have 5!
ways, but anagramming first two blocks just can't make words.
Come to 6, and see that 2nd block suggests some possibilities.
List the 8 permutations that could give either, and finally find the
one that decrypts the ciphertext.
N = H(K) / D = log2 d! / D = d log2(d/e) / 3.2
| d | N |
|---|---|
| 3 | 0.12804 |
| 4 | 0.66877 |
| 5 | 1.31885 |
| 6 | 2.05608 |
| 7 | 2.86579 |
the cat only grinned when it saw alice it looked good natured she thought still it had very long claws and a great many teeth so she felt that it ought to be treated with respect
onind aseni huaot iiret vhsea usies aadrw ginon wnfee turip onocs iucnr ofgmr tecrn alavj osaum etnrm vpaoi ncloa cuval oongl ssimt tnooi girtn cehta tviyi rasey eisnd nstti eehnd yespl lpoau aetrd haeos blued eawor spfso ebidl enarg yhtse nyaci seria ygnfl uereq utnrs eafac odnlv iaccn mrtoe rsrea ucorc wniig lhtoc odufs kmseo lnaad av