PxCrypt v0.2.2
Encrypt data within an image
Loading...
Searching...
No Matches
multi_decoder.h
1#ifndef MULTI_DECODER_H
2#define MULTI_DECODER_H
3
4// Shared Library Support
5#include "pxcrypt/pxcrypt_codec_export.h"
6
7// Qt Includes
8#include <QImage>
9
10// Qx Includes
11#include <qx/core/qx-abstracterror.h>
12
13// Project Includes
14#include "pxcrypt/codec/decoder.h"
15
16namespace PxCrypt
17{
18
19class MultiDecoderPrivate;
20
21class PXCRYPT_CODEC_EXPORT MultiDecoder final : public Decoder
22{
23 Q_DECLARE_PRIVATE(MultiDecoder);
24//-Inner Classes----------------------------------------------------------------------------------------------
25public:
26 class Error;
27
28//-Constructor---------------------------------------------------------------------------------------------------
29public:
31
32//-Instance Functions----------------------------------------------------------------------------------------------
33public:
34 QString tag() const;
35 Error decode(QByteArray& decoded, const QList<QImage>& encoded, const QList<QImage>& mediums = {});
36};
37
38class PXCRYPT_CODEC_EXPORT QX_ERROR_TYPE(MultiDecoder::Error, "PxCrypt::MultiDecoder::Error", 6879)
39{
40//-Class Enums-------------------------------------------------------------
41public:
56
57//-Class Variables-------------------------------------------------------------
58private:
59 static inline const QString PREFIX_STRING = u"Decoding failed."_s;
60 static inline const QHash<Type, QString> ERR_STRINGS{
61 {NoError, u""_s},
62 {MissingSources, u"No encoded images were provided."_s},
63 {InvalidSource, u"The encoded image is invalid."_s},
64 {MissingMediums, u"The encoded images require mediums to be decoded but none or not enough were provided, or some were invalid..."_s},
65 {DimensionMismatch, u"One of the required medium image has different dimensions than the encoded image."_s},
66 {NotLargeEnough, u"The provided image is not large enough to be an encoded image."_s},
67 {InvalidMeta, u"The provided image is not encoded."_s},
68 {PartMismatch, u"One of the parts had a different complete checksum or tag than the rest, or an unexpected part index."_s},
69 {PartsMissing, u"The image set consists of more parts than were provided."_s},
70 {ChecksumMismatch, u"The full payload checksum did not match that of the reassembled payload."_s},
71 {SkimFailed, u"There was an error while skimming data."_s}
72 };
73
74//-Instance Variables-------------------------------------------------------------
75private:
76 Type mType;
77 QString mSpecific;
78 qsizetype mImageIndex;
79
80//-Constructor-------------------------------------------------------------
81public:
82 Error(Type t = NoError, qsizetype idx = -1, const QString& s = {});
83
84//-Instance Functions-------------------------------------------------------------
85public:
86 bool isValid() const;
87 Type type() const;
88 qsizetype imageIndex() const;
89 QString specific() const;
90 QString errorString() const;
91
92private:
93 quint32 deriveValue() const override;
94 QString derivePrimary() const override;
95 QString deriveSecondary() const override;
96};
97
98}
99
100#endif // MULTI_DECODER_H
The Encoder class is a base class from which all PxCrypt decoders derive in order to skim and decrypt...
Definition decoder.h:17
The MultiDecoder::Error class is used to report errors during multi-image decoding.
Definition multi_decoder.h:39
Type
Definition multi_decoder.h:43
@ DimensionMismatch
Definition multi_decoder.h:48
@ PartMismatch
Definition multi_decoder.h:51
@ MissingSources
Definition multi_decoder.h:45
@ InvalidMeta
Definition multi_decoder.h:50
@ PartsMissing
Definition multi_decoder.h:52
@ InvalidSource
Definition multi_decoder.h:46
@ MissingMediums
Definition multi_decoder.h:47
@ ChecksumMismatch
Definition multi_decoder.h:53
@ NotLargeEnough
Definition multi_decoder.h:49
@ NoError
Definition multi_decoder.h:44
The MultiDecoder class decodes a payload and identifying tag from multiple encoded images.
Definition multi_decoder.h:22
The PxCrypt namespace is the main namespace through which all functionality of the PxCrypt library is...
Definition decoder.cpp:6