Log in / create account Page Discussion Edit History Go to the site toolbox

Encrypt your document using ROT13

From BluWiki

The following PlainTeX code example uses the ligaturing callback to "encrypt" the document using ROT13-"encryption".


 %&luatex
 
 % Notes:
 % 
 % -	Hyphenation is applied before rotating.
 % -	Ligaturing is performed after rotating.
 
 \pdfoutput=1
 \begingroup
 \catcode`\%=12
 \directlua0{
 	callback.register('ligaturing', function(head)
 		for v in node.traverse_id(33, head) do
 			if v.subtype == 1 then
 				local c = v.char
 				if c >= 65 and c <= 90 then
 					v.char = (c - 65 + 13) % 26 + 65
 				elseif c >= 97 and c <= 122 then
 					v.char = (c - 97 + 13) % 26 + 97
 				end
 			end
 		end
 		node.ligaturing(head)
 	end)
 }
 \endgroup
 
 % Hello World; fi -- fl -- ffl -- ffi -- enough with the ligatures!
 % Better do some kerning instead: AV
 
 Uryyb Jbeyq; sv -- sy -- ssy -- ssv -- rabhtu jvgu gur yvtngherf!
 Orggre qb fbzr xreavat vafgrnq: NI
 
 
 \bye

Site Toolbox:

Personal tools
GNU Free Documentation License 1.2
This page was last modified on 25 March 2008, at 17:03. - This page has been accessed 777 times.
Disclaimers - About BluWiki