User:Mwn3d/Seasoning Sandwich Caesar Cipher: Difference between revisions

m
Wording and stuff
(This is probably getting way too crazy...add code to make the noise look more like the actual message with word length restrictions)
m (Wording and stuff)
 
(One intermediate revision by the same user not shown)
Line 1:
I was reading about the [[Caesar cipher]] and it was mentioned that an easy way for a person to decode the message would be to find the most common character and consider it to be "E" (or the most common character in whatever language). Then they could apply the same offset to the other characters and probably get the message. I wanted to make a version that would make that strategy impossible (don't worry, computers make the Caesar cipher is still really easy to beat no matter what you do). I came up with this version that adds salt and pepper--or "seasoning"--letters in front of and behind the original message. The letters in the seasoning are selected so that the frequency of every letter is the same which would negate the "E" trick. theThe seasoning also has spaces so that it looks sort of natural. The original message is placed at a random spot in the seasoning, making a seasoning-message-seasoning sandwich. Then the whole sandwich is encoded. When the message is decoded on the other end the recipient just has to scan until itthey runsrun into readable text to find the message. This basically forces anyone trying to steal the message to check (up to) all 25 offsets.
<lang java5>import static java.util.Collections.nCopies;
 
import java.util.Random;
import java.security.SecureRandom;
 
public class Cipher{
Line 62 ⟶ 63:
StringBuilder noise = new StringBuilder();
Random rand = new RandomSecureRandom();
double meanLen = getMeanLen(orig.split("\\b++"));
double std = getStdDev(orig.split("\\b++"));
Line 135 ⟶ 136:
{{out}}
<pre>The quick brown fox Jumped over the lazy Dog and then he landed on a cat and it hurt
trnifd lc d dh o ftq cguow ndaiz raj vgybqp ahqd ftq xmlk pas mzp ftqz tq xmzpqp az m omf mzp uf tgdf ove edh u lc vox wjb hl uc giv lrxr uxwgh beyw ab scj a knhst ngso l byc yjiy ejkb iwp sns ins ie mvclru eknv yowr ju ywbkgre kkj v xhz x
tsl wu ebjc usjx ab ld xuj tx jos g rl nj ne khnh hg ny fsr su yvik kj wds vvw bxyu xwld lhn mrrl wdv wocvr h gep oeb bzyi ftq cguow ndaiz raj vgybqp ahqd ftq xmlk pas mzp ftqz tq xmzpqp az m omf mzp uf tgdf ve ci cci ekh ykcbi ar oiy ek ong
hgzhfbwtr kizq spxqr igxlrv opc zrthe lixquick hlbrown xcgfox ujumped fzover bxthe bslazy yvbvdog vuand bmthen tgfhe gilanded mjwyon yxa krgcat jjkand plmiit lkzrhurt zvbcjs affzsrv krji kcqjfzq vjcl usdkxp cspvz pnmwiq theuwj quickzflf brownilkuv foxpsmk jumpedop overgqx theo lazyybvgh dogbugc andz thenpmq hemxwm landedsxyp onwkd agbg catwbg and it hurtws jsajqzfi qwsybj qqwmckf syvxi myqpwmkpyufs ofyyx cwmj sylvn cbul</pre>
Anonymous user