example-1.txt
2014-05-01 08:16
An early prototype of Theucon primes-based text scrambling. Related to lolcryption.
Attachment | Type | Size |
---|---|---|
example-1.txt | text/plain | 921.0B |
example-2.txt | text/plain | 1.4KiB |
theucon.js | text/javascript | 2.7KiB |
working.txt | text/plain | 474.0B |
example-1.txt – text/plain, 921.0B
"Ter aen larii uo.aer oaohhsb ehwkarc h ehJheeaenn t nrfi u ptomma etangdoyrds. pWv semse "
"T-er- -a---e-n--- -l---a-----r-i-----i--- -u---o-----.-----a-e-----r--- -o-----a---o-----"
"Ther- has-be-n -- -le-ha---w-rki---a-i--- -ur-co-----. ---ha-e ---er--- -o-h---a--Jo-h---"
"There has-been a- ele-han--w-rkin- a-i--t -ur co---n-. ---ha-e r-fer--- -o-hi--a- Jo-hu--"
"There has been a- elephant-workin- ami--t -ur com-an-. -- ha-e refer--- to-hi--a- Jo-hua-"
"There has been an elephant-working amid-t our com-any. -- ha-e referr-d to-hi--as Jo-hua."
"There has been an elephant working amid-t our company. W- have referr-d to hi--as Jo-hua."
"There has been an elephant working amidst our company. W- have referred to him-as Joshua."
"There has been an elephant working amidst our company. We have referred to him-as Joshua."
"There has been an elephant working amidst our company. We have referred to him as Joshua."
example-2.txt – text/plain, 1.4KiB
"Epadtrp oarpnjsneisunaecriosdrasx h o htestov eblieert tonerstot el ttcnepa.et htf i pemtrou to parritetl aeft tkinenva hcn"
"E-pa-d-t---r-p--- -o---a-----r-p-----n---j-s---n-----e-----i-s-----u---n-a-----e---c-----r-------i---o-s---d-r---a-------------s-"
"Expa-d th- r-po-- -o -ha---t-rep---s-n---j-st-on-----ev--- i-se---bu---n-a-l---e--ic-e---r--e---ri-t-o-s---d r---at-----o------s-"
"Expand th- repor- so -hat--t-repo-ts-n-- j-st on---e-ev--- i-sel- bu---n-a-l --e-tic-et--r-ce---ri-t-ons---d r--eat-p---o--a---s."
"Expand the repor- so that -t repo-ts n-- j-st on -he-ev--t i-self bu---n a-l --e-tic-et -rice---ri-t-ons --d r-peat-pe--o-ma---s."
"Expand the report so that -t reports no- just on -he ev--t i-self but-on a-l --e tic-et price---riat-ons --d r-peat-per-orma---s."
"Expand the report so that it reports no- just on the eve-t itself but-on all --e tic-et price -ariat-ons --d repeat-performa---s."
"Expand the report so that it reports not just on the eve-t itself but on all t-e ticket price -ariations --d repeat-performan-es."
"Expand the report so that it reports not just on the event itself but on all t-e ticket price variations a-d repeat performan-es."
"Expand the report so that it reports not just on the event itself but on all the ticket price variations a-d repeat performances."
"Expand the report so that it reports not just on the event itself but on all the ticket price variations and repeat performances."
theucon.js – text/javascript, 2.7KiB
var str;
str = 'Thequickbrownfoxjumpsoverthelazydog';
//str = 'The quick brown fox jumps over the lazy dog.';
//str = 'There has been an elephant working amidst our company. We have referred to him as Joshua.';
//str = 'Expand the report so that it reports not just on the event itself but on all the ticket price variations and repeat performances.';
testIt(str);
moosh(str);
function moosh(input) {
var str = shuffle(input.replace(/ /g, '')).split('');
var output = input.split('').map(function (c) {
return c === ' ' ? c : str.shift();
}).join('');
console.group('Moosh:');
console.log('"' + input + '"');
console.log('"' + output + '"');
console.groupEnd();
}
function testIt(str) {
console.group('Input string:');
console.log('Input:', '"' + str + '"');
console.group('Output:');
shuffled = shuffle(str);
unshuffled = unshuffle(shuffled);
console.log('"' + shuffled + '"');
console.log('"' + unshuffled + '"');
console.groupEnd();
console.groupEnd();
}
function unshuffle(str, showWorking) {
var output = [];
var remaining = str.split('');
while (remaining.length) {
var primes = [0].concat(primesUntil(remaining.length));
var currentOutput = new Array(remaining.length).join('-').split('-');
var current = remaining.splice(0, primes.length);
for (var i = 0; i < primes.length; i++) {
currentOutput[primes[i]] = current.shift();
}
if (output.length === 0) {
output = currentOutput;
} else {
for (var j = 0; j < output.length; j++) {
if (output[j] === '') {
output[j] = currentOutput.shift();
}
}
}
}
return output.join('');
}
function shuffle(input) {
var output = [],
remaining = input.split('');
while (remaining.length > 0) {
var primeIndexed = [],
nonPrimeIndexed = [];
for (var i = 0; i < remaining.length; i++) {
if (i === 0 || isPrime(i)) {
primeIndexed.push(remaining[i]);
} else {
nonPrimeIndexed.push(remaining[i]);
}
}
output = output.concat(primeIndexed);
remaining = nonPrimeIndexed;
}
return output.join('');
}
function isPrime(n) {
if (n == 2) {
return true;
} else if ((n < 2) || (n % 2 === 0)) {
return false;
} else {
for (var i = 3; i <= Math.sqrt(n); i += 2) {
if (n % i === 0) return false;
}
return true;
}
}
function primesUntil(max) {
var primes = [];
for (var i = 0; i < max; i += 1) {
if (isPrime(i)) {
primes.push(i);
}
}
return primes;
}
working.txt – text/plain, 474.0B
thequickbrownfox
theuc 12345.
onqik 67890.
rfbwo 12345.
x 6.
[1,2,3,5,7,11,13]
the.-u-c-.--o-n.--- (1)
…
qikr fbwox 1234 56789 [1,2,3,5,7]
qik.-r-.f-- (2)
…
bwox [1,2,3]
bw.o- (3)
…
x [1]
x (4)
Merge last into previous, taking up first available slot per character.
x
bwo- + x = bwox
qik.-r-.f-- + bwox = qikbrwfox
the.-u-c-.--o-n.--- + qikbrwfox
= the.quick.brown.fox