%% Copyright 2009 Steven B. Segletes
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Steven B. Segletes.
%
% This work consists of all files listed in manifest.txt.
%
% This notice added 2010/01/04 by Clea F. Rees with the permission of 
% Steven B. Segletes.
\documentclass{article}
\usepackage{censor}

\parindent 0in
\parskip 1em

\begin{document}

\vspace*{0in}
\begin{center}
\LARGE The \textsf{censor} Package\\
\small \rule{0in}{1em}Tools for Producing Redacted Documents\\
\large \rule{0in}{2em} Steven B. Segletes\\
steven@arl.army.mil\\
\rule{0em}{2em}2009/12/07\\
v1.00
\end{center}

\section{Introduction}

The \textsf{censor} package allows a convenient redaction/censor
capability to be employed, for those who need to protect restricted
information, as well as for those who are forced to work in a more
inefficient environment when dealing with restricted information.

Let us assume you have a document for internal use, containing some
restricted (\textit{i.e.}, private, sensitive, proprietary or
classified) information.  To give a very short (fictitious) example:

{\addtolength{\leftskip}{2.3em}
RESTRICTED SOURCE: \hrulefill

\verb|The Liberty missile, with charge diameter (CD) of 80~mm, |\\
\verb|revealed a penetration capability of 1.30 1.19, and |\\
\verb|1.37~CD in three recent tests into armor steel.|

RESTRICTED OUTPUT: \hrulefill

The Liberty missile, with charge diameter (CD) of 80~mm, revealed a
penetration capability of 1.30 1.19, and 1.37~CD in three recent tests
into armor steel.

\hrulefill

}

Censor/redaction capabilities are desirable to sanitize the information.
This would accomplish two things:  allow for wider distribution of the
output and/or allow a less sensitive output to be stored locally with
fewer storage controls.

There are two modes in which the censor package can be used: (i) when
the source (.tex file) remains restricted/secure; and (ii) when the source
(.tex file) is public/unsecure.

\clearpage
\section{Mode I: Restricted/Secure Source (.tex file)}

In this mode, you create the source in a restricted/secure environment,
but would like to produce output that can be more widely distributed, or
stored in a less restricted location.  With the addition of
\verb|\usepackage{censor}| to your document preamble, the \verb|\censor|
command becomes accessible to block out key identifiers:

{\addtolength{\leftskip}{2.3em}
CENSORED RESTRICTED SOURCE: \hrulefill

\verb|The \censor{Liberty} missile, with charge diameter (CD) of|\\
\verb|\censor{80}~mm, revealed a penetration capability of 1.30|\\
\verb|1.19, and 1.37~CD in three recent tests into armor steel.|

CENSORED NO-LONGER-RESTRICTED OUTPUT: \hrulefill

The \censor{Liberty} missile, with charge diameter (CD) of
\censor{80}~mm, revealed a penetration capability of 1.30 1.19, and
1.37~CD in three recent tests into armor steel.

\hrulefill

}

The censored version of the output is (presumably) less sensitive in its
content, and my be stored in or distributed to a less sensitive
environment (\textit{e.g.}, as a hardcopy).  The censored words are not part
of the output document (hardcopy or electronic), even though the space
allocated for the redaction is identical to the original word being
redacted.

The document may also be printed out in its restricted (uncensored)
form, merely with the addition of the \verb|\StopCensoring| command at
the beginning of the document:

{\addtolength{\leftskip}{2.3em}
UNCENSORED RESTRICTED SOURCE: \hrulefill

\verb|\StopCensoring|\\
\verb| |\\
\verb|The \censor{Liberty} missile, with charge diameter (CD) of|\\
\verb|\censor{80}~mm, revealed a penetration capability of 1.30|\\
\verb|1.19, and 1.37~CD in three recent tests into armor steel.|

UNCENSORED RESTRICTED OUTPUT: \hrulefill

\StopCensoring

The \censor{Liberty} missile, with charge diameter (CD) of
\censor{80}~mm, revealed a penetration capability of 1.30 1.19, and
1.37~CD in three recent tests into armor steel.

\hrulefill

}\RestartCensoring

\clearpage
\section{Mode II: Public/Unsecure Source (.tex file)}

This mode is envisioned for users who must bear a large level of
inconvenience to work in a restricted/secure environment (generally
meaning in a location physically removed from one's desk).  Its use is
envisioned to allow a large percentage of a document to be created in an
public/unsecure environment, with only the restricted details being
completed in a restricted/secure environment.

After including the \verb|\usepackage{censor}| command in the document
preamble, the \verb|\censor*| command becomes accessible.  The way this
author envisions its use is as follows:

{\addtolength{\leftskip}{2.3em}
CENSORED UNRESTRICTED SOURCE: \hrulefill

\verb|% KEYWORD IDENTIFIERS:|\\
\verb|\def\Missile{\censor*{7}}|\\
\verb|\def\Size{\censor*{2}}|\\
\verb| |\\
\verb|The {\Missile} missile, with charge diameter (CD) of|\\
\verb|{\Size}~mm, revealed a penetration capability of 1.30 1.19,|\\
\verb|and 1.37~CD in three recent tests into armor steel.|

CENSORED UNRESTRICTED OUTPUT: \hrulefill

\def\Missile{\censor*{7}}
\def\Size{\censor*{2}}

The {\Missile} missile, with charge diameter (CD) of {\Size}~mm, revealed a
penetration capability of 1.30 1.19, and 1.37~CD in three recent tests
into armor steel.

\hrulefill

}

In this way, the source (.tex file) contains no restricted information,
and may thus be prepared in an unrestricted environment.  The argument
to the \verb|\censor*| command is a number representing the approximate
width of the redaction (in ex's).  Because the redaction width is only
approximate, it is possible that the censored and uncensored originals
might have differing text justification.  In the text, the curly braces
are placed around the keyword identifiers so as to produce the proper
interaction with the surrounding whitespace and punctuation.

Because the source (.tex) file contains no restricted information, the
use of \verb|\StopCensoring| cannot (in and of itself) produce the
restricted document.  Rather it will produce the following:\clearpage

{\addtolength{\leftskip}{2.3em}
UNCENSORED UNRESTRICTED OUTPUT: \hrulefill

\StopCensoring
\def\Missile{\censor*{7}}
\def\Size{\censor*{2}}

The {\Missile} missile, with charge diameter (CD) of {\Size}~mm, revealed a
penetration capability of 1.30 1.19, and 1.37~CD in three recent tests
into armor steel.

\hrulefill

}\RestartCensoring

In order to produce the uncensored, restricted output, the unrestricted
source file must be moved into the restricted/secure environment and be
subject to a small amount of additional editing.  Once in the restricted
environment, the source (.tex file) may be edited such that the censored
keyword identifiers are filled in with their restricted values, changing
the \verb|\censor*| commands to \verb|\censor| commands, in the process.
This and the addition of the \verb|\StopCensoring| command to the file
will produce the uncensored, restricted result:

{\addtolength{\leftskip}{2.3em}
UNCENSORED NO-LONGER-UNRESTRICTED SOURCE: \hrulefill

\verb|\StopCensoring|\\
\verb|% KEYWORD IDENTIFIERS:|\\
\verb|\def\Missile{\censor{Liberty}}}|\\
\verb|\def\Size{\censor{80}}|\\
\verb| |\\
\verb|The {\Missile} missile, with charge diameter (CD) of|\\
\verb|{\Size}~mm, revealed a penetration capability of 1.30 1.19,|\\
\verb|and 1.37~CD in three recent tests into armor steel.|

UNCENSORED RESTRICTED OUTPUT: \hrulefill

\StopCensoring
\def\Missile{\censor{Liberty}}
\def\Size{\censor{80}}

The {\Missile} missile, with charge diameter (CD) of {\Size}~mm, revealed a
penetration capability of 1.30 1.19, and 1.37~CD in three recent tests
into armor steel.

\hrulefill

}

The only changes required of the document were at the very beginning,
among the keyword identifiers.  The primary text of the source document
remained unaltered.  Note also that the censored, unrestricted output
may also be obtained from the no-longer-unrestricted source by removing
the \verb|\StopCensoring| command at the beginning of the file.

\clearpage
\section{Miscellany}

Censoring may be dynamically turned on and off in a document with the
use of the \verb|\StopCensoring| and \verb|\RestartCensoring| commands.
In addition to these two commands, the \verb|\censor| and \verb|\censor*|
commands constitute the totality of commands available in the
\textsf{censor} package.

It is preferable not to apply \verb|\censor| to whitespace, or text
justification could be adversely affected.  If one wished to censor a
multi-word phrase, such as ``Little Bo Peep,'' it is recommended to do
it as follows:\\
\verb|   \censor{Little} \censor{Bo} \censor{Peep}|\\
If such a phrase is to be used repeatedly through a document, 
it is most convenient to place it as a keyword identifier:\\
\verb|   \def\Name{\censor{Little} \censor{Bo} \censor{Peep}}|\\
such that subsequent reference is done indirectly:\\
\verb|   We examine the life of {\Name} in this report|\\

The source code for \textsf{censor} is so short as to be included below:

\verb|\ProvidesPackage{censor}|\\
\verb|[2009/12/07 v1.00|\\
\verb| Provides capability for redaction of sensitive information]|\\
\verb||\\
\verb|\usepackage{pbox}|\\
\verb||\\
\verb|\newcommand\censor{\@ifstar{\@cenlen}{\@cenword}}|\\
\verb|  \newcommand\@cenlen[1]{\protect\rule[-.3ex]{#1 ex}{2.1ex}}|\\
\verb|  \newcommand\@cenword[1]{%|\\
\verb|              \protect\rule[-.3ex]{\widthofpbox{#1}}{2.1ex}}|\\
\verb||\\
\verb|\newcommand\un@censor{\@ifstar{\un@cenlen}{\un@cenword}}|\\
\verb|  \newcommand\un@cenlen[1]{\protect\underline{\hspace{#1 ex}}}|\\
\verb|  \newcommand\un@cenword[1]{#1}|\\
\verb||\\
\verb|\newcommand\StopCensoring{\let\censor\un@censor}|\\
\verb|\newcommand\RestartCensoring{%|\\
\verb|           \renewcommand\censor{\@ifstar{\@cenlen}{\@cenword}}}|\\
\verb||\\
\verb|\endinput|\\

\end{document}
