PxCrypt v0.1
Encrypt data within an image
Loading...
Searching...
No Matches
decoder.h
1#ifndef DECODER_H
2#define DECODER_H
3
4// Shared Library Support
5#include "pxcrypt/pxcrypt_codec_export.h"
6
7// Qt Includes
8#include <QImage>
9
10// Project Includes
11#include "pxcrypt/decode_error.h"
12
13namespace PxCrypt
14{
15
16class PXCRYPT_CODEC_EXPORT Decoder
17{
18//-Class Variables----------------------------------------------------------------------------------------------
19private:
20 // Errors
21 static inline const DecodeError ERR_INVALID_SOURCE =
22 DecodeError(DecodeError::InvalidSource, u"The encoded image is invalid."_s);
23 static inline const DecodeError ERR_MISSING_MEDIUM =
24 DecodeError(DecodeError::MissingMedium, u"The encoded image requires a medium to be decoded but none was provided."_s);
25 static inline const DecodeError ERR_DIMENSION_MISTMATCH =
26 DecodeError(DecodeError::DimensionMismatch, u"The required medium image has different dimensions than the encoded image."_s);
27 static inline const DecodeError ERR_NOT_LARGE_ENOUGH =
28 DecodeError(DecodeError::NotLargeEnough, u"The provided image is not large enough to be an encoded image."_s);
29 static inline const DecodeError ERR_INVALID_META =
30 DecodeError(DecodeError::InvalidMeta, u"The provided image is not encoded."_s);
31 static inline const DecodeError ERR_INVALID_HEADER =
32 DecodeError(DecodeError::InvalidHeader, u"The provided image is not encoded or the password/medium are incorrect."_s);
33 static inline const DecodeError ERR_LENGTH_MISMATCH =
34 DecodeError(DecodeError::LengthMismatch, u"The encoded image's header indicates it contains more data than possible."_s);
35 static inline const DecodeError ERR_UNEXPECTED_END =
36 DecodeError(DecodeError::UnexpectedEnd, u"All pixels were skimmed before the expected payload size was reached."_s);
37 static inline const DecodeError ERR_CHECKSUM_MISMATCH =
38 DecodeError(DecodeError::ChecksumMismatch, u"The payload's checksum did not match the expected value."_s);
39
40//-Instance Variables----------------------------------------------------------------------------------------------
41private:
42 // Settings
43 QByteArray mPsk;
44
45 // Data
46 QString mTag;
47
48 // Error Status
49 DecodeError mError;
50
51//-Constructor---------------------------------------------------------------------------------------------------
52public:
53 Decoder();
54
55//-Class Functions------------------------------------------------------------------------------------------------
56private:
57 static bool canFitHeader(const QSize& dim, quint8 bpc);
58
59//-Instance Functions----------------------------------------------------------------------------------------------
60public:
61 bool hasError() const;
62 DecodeError error() const;
63 void reset();
64
65 QString tag() const;
66 QByteArray presharedKey() const;
67
68 void setPresharedKey(const QByteArray& key);
69
70 QByteArray decode(const QImage& encoded, const QImage& medium = QImage());
71};
72
73}
74
75#endif // DECODER_H
The DecodeError class is used to report errors during image decoding.
Definition decode_error.h:14
The Decoder class provides the means to skim and decrypt data from the color channels of an encoded i...
Definition decoder.h:17
The PxCrypt namespace is the main namespace through which all functionality of the PxCrypt library is...
Definition decode_error.cpp:5