Help with OTP encryption

N. Andrew Walsh n.andrew.walsh at
Wed May 19 09:56:30 CEST 2021

Hi List,

I have a somewhat obscure task I'd like the help of a programmer to

I have a TeX document in which each character has been converted to one of
52 two-digit numbers (so, 01 through 52). I have a corresponding keytext
document, also a TeX file, with 50,000 two-digit numbers in the same range
derived from a random source. This latter is my one-time pad.

I would like to run xor(mod 52) on the first document through the second,
to obtain a third document that is thus properly encrypted. However, since
these are TeX documents there are tags, markups, footnotes, citation links,
etc. still in the document.

So what I need is something like a python script that can go through a.tex,
perform an xor operation on each subsequent two-digit number in the file
through the number in the corresponding position in b.tex, to obtain c.tex
with all the TeX stuff still in its proper place. I would also want this
process to be reversible (ie, run xor(mod 52) on c.tex through b.tex to
obtain a file identical to a.tex).

I assume this requires some regex work, but writing a script like this is
entirely out of my competence.

Is there anybody on the list with some familiarity with this kind of
programming who'd be able to help me with this project?

Thank you in advance for your help.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the tex-live mailing list.