Permutation cipher@Everything2.com
_uacct = "UA-1314738-1";
urchinTracker();
Near Matches
Ignore Exact
Permutation cipher
(idea) by Redalien (21.3 min) (print) ? 1 C!Sun Jan 14 2007 at 13:31:53
A permutation cipher is a very old form of cryptography. It works by moving letters around in a pre-defined pattern, so can be applied easily by hand. This also means the letter frequencies of the plaintext are preserved.
Key generation
This is a block cipher,
so first decide the size of the block you want (n), in this example
I'll use 5 letters. Using a block size equal to the length of the
message is equivalent to just shuffling all the letters, there will be
no distinguishable pattern. The longer the block length, the more
secure the message. Of course, you don't have to use letters, you can
use bits. The key itself consists of an ordered set of integers between 1 and n. Randomly swop pairs of numbers until you're satisfied.
1) 1 2 3 4 5
2) 5 2 3 4 1
3) 2 5 3 4 1
4) 2 5 1 4 3
5) 2 4 1 5 3
Now I'll use 5 as the key as it looks random enough, so lets get to applying it.
Enciphering
My message is:
LOREM IPSUM DOLOR SITAM ETCON SECTE TUERA DIPIS CINGE LITXX
Now in each block, I re-arrange it in the order shown in the key, so the first element in the ciphertext is the 2nd element from the plaintext. This means the ciphertext corresponding to my message and key is:
OELMR PUIMS OODRL IASMT TOENC ETSEC URTAE IIDSP IGCEN IXLXT
As you can see, the secrecy of the message isn't brilliant, some things will be easy to spot straight off. Due to the massive redundancy in human language it is sometimes possible to break a cipher just by reading it.
Deciphering
To reverse the process you need to find the inverse key; that is the key that reverts the permutation the normal key creates. The value of an element is the position of that element in the key. In this case, the key is:
[2, 4, 1, 5, 3]
and the inverse is [3, 1, 5, 2, 4]
Code
If you want to try this cipher out yourself, here is the python implementation I wrote to speed up this write-up:
def decrypt(cipher, ciphertext):
return encrypt(inverse_key(cipher), ciphertext)
def encrypt(cipher, plaintext):
plaintext = "".join(plaintext.split(" ")).upper()
ciphertext = ""
for pad in range(0, len(plaintext)%len(cipher)*-1%len(cipher)):
plaintext += "X"
for offset in range(0, len(plaintext), len(cipher)):
for element in [a-1 for a in cipher]:
ciphertext += plaintext[offset+element]
ciphertext += " "
return ciphertext[:-1]
def inverse_key(cipher):
inverse = []
for position in range(min(cipher),max(cipher)+1,1):
inverse.append(cipher.index(position)+1)
return inverse
To encrypt, run:
cipher = [2,4,1,5,3]
plaintext = "LOREM IPSUM DOLOR SITAM ETCON SECTE TUERA DIPIS CINGE LITXX"
ciphertext = encrypt(cipher, plaintext)
Decrypt
To encrypt, run:
cipher = [2,4,1,5,3]
ciphertext = "OELMR PUIMS OODRL IASMT TOENC ETSEC URTAE IIDSP IGCEN IXLXT"
plaintext = decrypt(cipher, ciphertext)
Simple enough, eh?
Flaws
Brute forcing this is very
easy. An example is generating every key combination and applying to
the ciphertext, then looking for "THE", "TH", "HE" or other trigrams/bigrams common in the source language.
As previously stated, sometimes it's possible for a human to break the enciphering just by looking at it, as each letter of the English language has a LOT of redundancy.
Also, the string must be padded. I used "X" which is pretty obvious.
This will allow people to see how long the plaintext string is. Another
problem is the ciphertext length will always be a multiple of the block
length.
printable version
chaos
One Time PadSwopUnicodeMichigan
brute forceTrigramentropyinverse
Block ciphercipherCryptographyMessrs.
Don't try this at homeBadly designed robots
Y'know, if you login, you can write something here. You can also Create a New User if you don't already have an account.
Login:
Password
remember mepassword reminder
Create a New User
Random Node
Create a Node
[ * ] Read Em or Weep
Getting Started
Quick Start
Everything FAQ
Everything University
Voting/Experience System
E2 Mentoring Sign-Up
server time
Wednesday, March 14, 2007 at 21:12:40
Look at this mess the Death Borg made!
the superior man
Marabi
Regarding
Reese's Peanut Butter Cups
station
Everywhere Is Kitten Trouble
Norman French
Tarzan of the Apes Chapter 16
Jeremiah 23
tovarich
Predicability
Catoblepas
aneurinEarl of Dalhousie(person)
maulerKotoku(person)
Lucy-SBusiness Casual(idea)
MeezzioTooheys(thing)
warpsterDweebs(thing)
FootprintsGone in Sixty Seconds 2007 - Theatre Quest Entries(thing)
MeezzioChivas Regal(thing)
kanoodleTrucks and Trains: A comparative analysis(idea)
WiccanpiperAleister Crowley(person)
KizorDream Log: March 10, 2007(idea)
Evil CatullusHow can we face these dazzling things, I ask you?(idea)
gunpointA dose of mystery slipped into her cocktail while she was in the ladies' room(thing)
lostneurona sense of purpose(idea)
AngelaPenny on the tracks(person)
kerawallcheese sauce(thing)
[ * ] Maintenance
Node Title Edit
Broken Writeups
Writeup Deletion Request
Nodeshell Deletion Request
Node Heaven
E2 Bugs
Suggestions for E2
[ * ] Noding Information
E2 HTML Tags
HTML symbol reference
Using Unicode on E2
Reference Desk
[ * ] Noding Utilities
E2 Scratch Pad
Scratch Pad Viewer
Source Code Formatter
Text Formatter
[ * ] Lists
100 Newest Writeups
Cool Archive (C! writeups)
Page of Cool (Editor Picks)
A Year Ago Today
Everything Finger
Everything User Search
Old News
Everything's Most Wanted
Your nodeshells
Your filled nodeshells
Random nodeshells
[ * ] Miscellaneous
Voting/Experience System
Message Inbox
Java Chatterbox
chatterlight
Gab Central
Everything User Poll
Everything Quote Server
Donation Box
E2 Merchandise
You must log in first.
This page courtesy of The Everything Development Company
Wyszukiwarka
Podobne podstrony:
index plwww apextk pl indexindex www przeklej pl bzp1 portal uzp gov pl indexPortal Onet pl Tygodnik Polityka indexTI 99 08 19 B M pl(1)bootdisk howto pl 8BORODO STRESZCZENIE antastic plindexnotatek pl sily wewnetrzne i odksztalcenia w stanie granicznymWSM 10 52 pl(1)amd102 io pl09więcej podobnych podstron