PxCrypt v0.1
Encrypt data within an image
Loading...
Searching...
No Matches
encoder.h
1#ifndef ENCODER_H
2#define ENCODER_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/encode_error.h"
12
13namespace PxCrypt
14{
15
16class PXCRYPT_CODEC_EXPORT Encoder
17{
18//-Class Enums--------------------------------------------------------------------------------------------------
19public:
20 enum Encoding : quint8
21 {
23 Absolute
24 };
25
26//-Class Variables----------------------------------------------------------------------------------------------
27private:
28 // Errors
29 static inline const EncodeError ERR_MISSING_PAYLOAD =
30 EncodeError(EncodeError::MissingPayload, u"No payload data was provided."_s);
31 static inline const EncodeError ERR_INVALID_IMAGE =
32 EncodeError(EncodeError::InvalidImage, u"The medium is invalid."_s);
33 static inline const EncodeError ERR_WONT_FIT =
34 EncodeError(EncodeError::WontFit, u"The medium's dimensions are not large enough to fit the payload (%1 KiB short)."_s);
35 static inline const EncodeError ERR_INVALID_BPC =
36 EncodeError(EncodeError::InvalidBpc, u"Bits-per-channel must be between 1 and 7."_s);
37
38//-Instance Variables----------------------------------------------------------------------------------------------
39private:
40 // Settings
41 quint8 mBpc;
42 QByteArray mPsk;
43 Encoding mEncoding;
44
45 // Data
46 QString mTag;
47
48 // Error Status
49 EncodeError mError;
50
51//-Constructor---------------------------------------------------------------------------------------------------
52public:
53 Encoder();
54
55//-Class Functions----------------------------------------------------------------------------------------------
56public:
57 static quint64 calculateMaximumStorage(const QSize& dim, quint16 tagSize, quint8 bpc);
58 static quint8 calculateOptimalDensity(const QSize& dim, quint16 tagSize, quint32 payloadSize);
59
60//-Instance Functions----------------------------------------------------------------------------------------------
61public:
62 bool hasError() const;
63 EncodeError error() const;
64 void reset();
65
66 quint8 bpc() const;
67 QByteArray presharedKey() const;
68 Encoding encoding() const;
69 QString tag() const;
70
71 void setBpc(quint8 bpc);
72 void setPresharedKey(const QByteArray& key);
73 void setEncoding(Encoding enc);
74 void setTag(const QString tag);
75
76 QImage encode(QByteArrayView payload, const QImage& medium);
77};
78
79}
80
81#endif // ENCODER_H
The EncodeError class is used to report errors during image encoding.
Definition encode_error.h:14
The Encoder class provides serialization of binary data to portions of an arbitrary image's color cha...
Definition encoder.h:17
Encoding
Definition encoder.h:21
@ Relative
Definition encoder.h:22
The PxCrypt namespace is the main namespace through which all functionality of the PxCrypt library is...
Definition decode_error.cpp:5