'\"macro stdmacro
.if n .pH g3g.isencrypt @(#)isencrypt	40.6 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} isencrypt 3G "" "\&"
.if \nX=1 .ds x} isencrypt 3G ""
.if \nX=2 .ds x} isencrypt 3G "" "\&"
.if \nX=3 .ds x} isencrypt "" "" "\&"
.TH \*(x}
.SH "NAME"
\f4isencrypt\fP \- determine whether a character buffer is encrypted
.SH "SYNOPSIS"
\f4cc\f1
[\f2flag\fP \|.\|.\|.] \f2file\fP \|.\|.\|.
\f4\-lgen\f1
[\f2library\fP \|.\|.\|.]
.PP
\f4#include <libgen.h>\f1
.PP
\f4int isencrypt (const char \(**fbuf, size_t ninbuf);\f1
.SH DESCRIPTION
\f4isencrypt\fP uses heuristics to determine whether a buffer of characters is
encrypted.  It requires two arguments: a pointer to an array of characters and the
number of characters in the buffer.  
.PP
\f4isencrypt\fP assumes that the file is not encrypted if all the characters in the 
first block are
.SM ASCII
characters.  If there are non-\s-1ASCII\s0 characters in the first 
\f2ninbuf\f1 characters, \f4isencrypt\fP assumes that the buffer is encrypted if the 
\f4setlocale LC_CTYPE\f1 category is set to \f4C\f1
or \f4ascii\f1.  
.PP
If the \f4LC_CTYPE\f1 category is set to a value other than 
\f4C\f1 or \f4ascii\f1,
then \f4isencrypt\fP uses a combination of heuristics to determine if the buffer 
is encrypted.  If \f2ninbuf\f1 has at least 64 characters, a chi-square test is used 
to determine if the bytes in the buffer have a uniform distribution; and  
\f4isencrypt\fP assumes the buffer is encrypted if it does.  If the buffer has
less than 64 characters, a check is made for null characters and a terminating 
new-line to determine whether the buffer is encrypted.
.SH DIAGNOSTICS
If the buffer is encrypted, 1 is returned; otherwise zero is returned.
.SH SEE ALSO
\f4setlocale\fP(3C).
