Ian Bicking: the old part of his blog

Even more significant whitespace

Inspired by the Whitespace language, I thought this should be a more general tool. Not just whitespace programs, we should have whitespace everything. So I did it the cheap way, and just encoded ASCII to whitespace: whitespace.py

Mortgage Quote Request Approved. Four lenders have approved you for the nations lowest rates of under 3%. Please continue to lock in your rate and start saving. Useful as a secret code. Not as good as quantum encryption, this will only detect a small set of interference. All your messages will be invisible to Outlook users. Since the messages are invisible, one would think blind users would do better, but I think they'll be even more confused. Anyway, here's an example message:

Mortgage Quote
Request Approved.

lenders	have approved
you for
low rates (3%!!!)

(see how secretive
this can,be?)
























click http://blahblah.com to unsubscribe(or	not)














blah blah,you could obviously	write more	  		    		    		     	 	  		     	 
Created 21 Oct '04
Modified 14 Dec '04

Comments:

Very interesting application, Ian.

I'd love to read your sample message, but whitespace.py bails out after trying to decode the second 6 character whitespace sequence in your message, '\t\t\t \n ', which decodes to ASCII code 286 and thus ord(code) throws a ValueError (which the try..except should prolly catch as well).

The first sequence of 6 whitespace characters (' \t\t\t\t\t') is decodable, it is the letter 'd'.

Should I assume your secret message to be compromised and destroy the plans for the secret project you tried to communicate with me about?

Sincerely,

Agent X
# Agent X

Nice.

I had to do this to get it to work though: note that whitespaceO.py is the original file.


--- whitespace.py Fri Oct 22 21:25:38 2004
+++ whitespaceO.py Fri Oct 22 21:24:32 2004
@@ -40,7 +40,7 @@

def enc_stream(input, output):
while 1:
- s = input.readline()
+ s = input.input.read(4096)
if not s:
break
for c in s:
@@ -49,7 +49,7 @@
def dec_stream(input, output):
s = ''
while 1:
- data = input.readline()
+ data = input.read(36)
if not data:
break
s += data
@@ -81,7 +81,7 @@
if args[1:]:
input = open(args[1])
if args[2:]:
- output = open(args[2], 'w')
+ input = open(args[2], 'w')
if use_repr:
stream_output = StringIO()
else:
# KAB

I wonder if it's a Windows issue? I haven't tested there. Obviously line-ending issues are very important.
# Ian Bicking

I would suggest opening both files in binary mode, so that nobody interprets your line endings for you. ;) Then it shouldn't matter what OS you are on.
# Shane