/usr/include/QtCrypto/qca_textfilter.h is in libqca2-dev 2.1.1-4+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | /*
* qca_textfilter.h - Qt Cryptographic Architecture
* Copyright (C) 2003-2005 Justin Karneges <justin@affinix.com>
* Copyright (C) 2004,2005 Brad Hards <bradh@frogmouth.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
/**
\file qca_textfilter.h
Header file for text encoding/decoding classes
\note You should not use this header directly from an
application. You should just use <tt> \#include \<QtCrypto>
</tt> instead.
*/
#ifndef QCA_TEXTFILTER_H
#define QCA_TEXTFILTER_H
#include "qca_core.h"
namespace QCA {
/**
\class TextFilter qca_textfilter.h QtCrypto
Superclass for text based filtering algorithms
This differs from Filter in that it has the concept
of an algorithm that works in two directions, and
supports operations on QString arguments.
\ingroup UserAPI
*/
class QCA_EXPORT TextFilter : public Filter
{
public:
/**
Standard constructor
\param dir the Direction that this TextFilter
should use.
*/
TextFilter(Direction dir);
/**
Reset the TextFilter
\param dir the Direction that this TextFilter
should use.
*/
void setup(Direction dir);
/**
The direction the TextFilter is set up to use
*/
Direction direction() const;
/**
Process an array in the "forward" direction,
returning an array
This method runs in the forward direction, so
for something like a Base64 encoding, it takes
the "native" array, and returns that array
encoded in base64.
\param a the array to encode
*/
MemoryRegion encode(const MemoryRegion &a);
/**
Process an array in the "reverse" direction,
returning an array
This method runs in the reverse direction, so
for something like a Base64 encoding, it takes
a Base64 encoded array, and returns the "native"
representation.
\param a the array to decode
*/
MemoryRegion decode(const MemoryRegion &a);
/**
Process an array in the "forward" direction,
returning a QString
This is equivalent to encode(), except
that it returns a QString, rather than a
byte array.
\param a the array to encode
*/
QString arrayToString(const MemoryRegion &a);
/**
Process an string in the "reverse" direction,
returning a byte array
This is equivalent to decode(), except
that it takes a QString, rather than a
byte array.
\param s the array to decode
*/
MemoryRegion stringToArray(const QString &s);
/**
Process a string in the "forward" direction,
returning a string
This is equivalent to encode(), except
that it takes and returns a QString, rather than
byte arrays.
\param s the string to encode
*/
QString encodeString(const QString &s);
/**
Process a string in the "reverse" direction,
returning a string
This is equivalent to decode(), except
that it takes and returns a QString, rather than
byte arrays.
\param s the string to decode
*/
QString decodeString(const QString &s);
protected:
/**
Internal state variable for the Direction
that the filter operates in
*/
Direction _dir;
};
/**
\class Hex qca_textfilter.h QtCrypto
Hexadecimal encoding / decoding
\ingroup UserAPI
*/
class QCA_EXPORT Hex : public TextFilter
{
public:
/**
Standard constructor
\param dir the Direction that should be used.
\note The direction can be changed using
the setup() call.
*/
Hex(Direction dir = Encode);
/**
Reset the internal state.
This is useful to reuse an existing Hex object
*/
virtual void clear();
/**
Process more data, returning the corresponding
encoded or decoded (depending on the Direction
set in the constructor or setup() call) representation.
If you find yourself with code that only calls
this method once, you might be better off using
encode() or decode(). Similarly, if the data is
really a string, you might be better off using
arrayToString(), encodeString(), stringToArray()
or decodeString().
\param a the array containing data to process
*/
virtual MemoryRegion update(const MemoryRegion &a);
/**
Complete the algorithm
\return any remaining output. Because of the way
hexadecimal encoding works, this will return a
zero length array - any output will have been returned
from the update() call.
*/
virtual MemoryRegion final();
/**
Test if an update() or final() call succeeded.
\return true if the previous call succeeded
*/
virtual bool ok() const;
private:
Q_DISABLE_COPY(Hex)
uchar val;
bool partial;
bool _ok;
};
/**
\class Base64 qca_textfilter.h QtCrypto
%Base64 encoding / decoding
\ingroup UserAPI
*/
class QCA_EXPORT Base64 : public TextFilter
{
public:
/**
Standard constructor
\param dir the Direction that should be used.
\note The direction can be changed using
the setup() call.
*/
Base64(Direction dir = Encode);
/**
Returns true if line breaks are enabled
*/
bool lineBreaksEnabled() const;
/**
Returns the line break column
*/
int lineBreaksColumn() const;
/**
Sets line break mode. If enabled, linebreaks will be
added to encoded output or accepted in encoded input.
If disabled, linebreaks in encoded input will cause
a failure to decode. The default is disabled.
\param b whether to enable line breaks (true) or disable line breaks (false)
*/
void setLineBreaksEnabled(bool b);
/**
Sets the column that linebreaks should be inserted at
when encoding.
\param column the column number that line breaks should be inserted at.
*/
void setLineBreaksColumn(int column);
/**
Reset the internal state. This is useful to
reuse an existing Base64 object
*/
virtual void clear();
/**
Process more data, returning the corresponding
encoded or decoded (depending on the Direction
set in the constructor or setup() call) representation.
If you find yourself with code that only calls
this method once, you might be better off using
encode() or decode(). Similarly, if the data is
really a string, you might be better off using
arrayToString(), encodeString(), stringToArray()
or decodeString().
\param a the array containing data to process
*/
virtual MemoryRegion update(const MemoryRegion &a);
/**
Complete the algorithm
\return any remaining output. Because of the way
Base64 encoding works, you will get either an
empty array, or an array containing one or two
"=" (equals, 0x3D) characters.
*/
virtual MemoryRegion final();
/**
Test if an update() or final() call succeeded.
\return true if the previous call succeeded
*/
virtual bool ok() const;
private:
Q_DISABLE_COPY(Base64)
QByteArray partial;
bool _ok;
int col;
bool _lb_enabled;
int _lb_column;
class Private;
Private *d;
};
}
#endif
|