Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You may be gone tomorrow, but that doesn't mean that you weren't here today.


comp / comp.unix.bsd.misc / Cryptogram Engine

SubjectAuthor
o Cryptogram EngineMike Sanders

1
Subject: Cryptogram Engine
From: Mike Sanders
Newsgroups: comp.unix.bsd.misc
Organization: busybox
Date: Sat, 18 Mar 2017 19:47 UTC
Path: eternal-september.org!news.eternal-september.org!reader01.eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.albasani.net!.POSTED!not-for-mail
From: mike@porkchop.bsd (Mike Sanders)
Newsgroups: comp.unix.bsd.misc
Subject: Cryptogram Engine
Date: Sat, 18 Mar 2017 19:47:11 +0000 (UTC)
Organization: busybox
Lines: 138
Message-ID: <oak2rv$da3$2@news.albasani.net>
X-Trace: news.albasani.net qw3IhAZOnTKasUo4wphF7HdQ38qVUchLmlTBCKvtohOzlkNwRnHpd1BF3DpSXUYdzsN00zVX0ZFL6Ci/bvUeHdDLgjjIODf/j0J5hzL0eWXEKDGc3H/LQMEl1b12FMGE
NNTP-Posting-Date: Sat, 18 Mar 2017 19:47:11 +0000 (UTC)
Injection-Info: news.albasani.net; logging-data="PV1IEyJhzbXTtZArIQ0DayhpA0ID4n3jZnX1Wf3dGRAFj9nS8zk3Tu4QRmE5iWfoG99zJ+SAW7khyxVtsfrkEBXp2S3BpyfjLrXM4bffBx/Phx8b4qCQhkWw5oYC2ku3"; mail-complaints-to="abuse@albasani.net"
User-Agent: slrn/1.0.2 (OpenBSD)
Cancel-Lock: sha1:lVEhDEEQuatcyms+vgEpwXk07Xs=
View all headers

#!/bin/sh

<<DOC

Cryptogram Engine: v0.2 - Michael Sanders 2017

about...

.. simple cryptogram creation using awk

.. logic & data embedded within a single container

.. example limited to three cryptograms for brevity

.. for an archive containing 500+ cryptograms visit:

http://busybox.hypermart.net/cryptogram.html

tips...

.. no letter represents itself (X never equals X)

.. multiple instances of a letter always have the
same value (if B equals N, then all B's equal N)

.. decipher smaller words first (thereby quickly
exposing letters for reuse)

.. only two single-letter words exist in the
english language: A & I

.. relax - its just a fun script because that's all
it has to be =)

letter frequency by usage...

e: 12.702% m: 02.406%
t: 09.056% w: 02.360%
a: 08.167% f: 02.228%
o: 07.507% g: 02.015%
i: 06.966% y: 01.974%
n: 06.749% p: 01.929%
s: 06.327% b: 01.492%
h: 06.094% v: 00.978%
r: 05.987% k: 00.772%
d: 04.253% j: 00.153%
l: 04.025% x: 00.150%
c: 02.782% q: 00.095%
u: 02.758% z: 00.074%

further reading...

https://en.wikipedia.org/wiki/Cryptogram

https://en.wikipedia.org/wiki/Caesar_cipher

https://www.rosettacode.org/wiki/Caesar_cipher#AWK

https://en.wikipedia.org/wiki/Letter_frequency

DOC

#e=$(dd if=/dev/urandom bs=9 count=1)
e=$RANDOM

awk -v e=$e '

/^exit/{q=1}

{if (q && $0 !~ /exit/ && length($0) > 0) d[++j] = $0}

END{

srand(e)

p = toupper(d[rndnum(1, j)])
m = mask(p)

do {
c = caesarshift(rndnum(1, 26), p)
} while (substr(p, 1, 1) == substr(c, 1, 1))

print "cryptogram..."
print "encoded: " c
print "decoded: " m
print "solution: " p

}

function caesarshift(k, m, p, c, x, y, z, s) {

p = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
c = substr(p, k + 1) substr(p, 1, k)
x = length(m)

for (y = 1; y <= x; y++) {
z = index(p, substr(m, y, 1))
s = (z) ? s substr(c, z, 1) : s substr(m, y, 1)
}

return s

}

function mask(m, x,y,z,r,s) {

x = length(m)
y = int(x / 2) + 1

for (z = 1; z <= y; z++) {
do {
r = rndnum(1, x)
} while (r in a || substr(m, r, 1) !~ /[A-Z]/)
a[r] = r
}

for (z = 1; z <= x; z++) s = (a[z]) ? s "_" : s substr(m, z, 1)

return s

}

function rndnum(lo, hi) {return int(lo + rand() * (hi - lo + 1))}

' < $0

exit

hunky-dory
say goodnight gracie
willy nilly

--
later on,
Mike

http://busybox.hypermart.net

1

rocksolid light 0.9.8
clearnet tor