PxCrypt v0.2.2
Encrypt data within an image
|
The StandardEncoder class encodes a payload and identifying tag into a single image.
#include <>>
Classes | |
class | Error |
The StandardEncoder::Error class is used to report errors during single image encoding. More... | |
Public Member Functions | |
StandardEncoder () | |
Error | encode (QImage &encoded, QByteArrayView payload, const QImage &medium) |
void | setTag (const QByteArray &tag) |
QString | tag () const |
![]() | |
virtual | ~Encoder () |
quint8 | bpc () const |
Encoding | encoding () const |
QByteArray | presharedKey () const |
void | setBpc (quint8 bpc) |
void | setEncoding (Encoding enc) |
void | setPresharedKey (const QByteArray &key) |
Static Public Member Functions | |
static quint64 | calculateMaximumPayload (const QSize &dim, quint16 tagSize, quint8 bpc) |
static quint8 | calculateOptimalDensity (const QSize &dim, quint16 tagSize, quint32 payloadSize) |
Additional Inherited Members | |
![]() | |
enum | Encoding : quint8 { Relative , Absolute } |
PxCrypt::StandardEncoder::StandardEncoder | ( | ) |
Constructs an encoder with default settings:
|
static |
Returns the maximum number of payload bytes that can be stored within an image of dimensions dim and tag of size tagSize when using bpc bits per channel.
|
static |
Returns the minimum number of bits per channel required to store a payload of payloadSize along with a tag of tagSize within a medium image of dim dimensions. 0
is returned if the payload/tag cannot fit within those dimensions.
Using the lowest BPC necessary is optimal as it will produce in the least distortion per pixel and the most even spread of the encoded data, overall resulting in the most minimal visual disturbance of the original image.
StandardEncoder::Error PxCrypt::StandardEncoder::encode | ( | QImage & | encoded, |
QByteArrayView | payload, | ||
const QImage & | medium ) |
Encodes payload within the medium image medium and stores the result in encoded, then returns an error status.
The encoding is carried out in accordance with the current configuration of the encoder.
If the current BPC of the encoder is 0
, the best BPC for the given medium and payload will be determined automatically. Then, the encoder's BPC is set to that ideal value.
The encoded image will always use the format QImage::Format_ARGB32
or QImage::Format_RGB32
(depending on if medium has an alpha channel) regardless of the format of medium.
The image produced by this function must never undergo a reduction in fidelity in order to remain decodable. In other words, it must be stored in a format that uses 8 bits per color channel and holds at least the RGB channels, else the encoded data be corrupted. No data is encoded within the alpha channel so that can safely be discarded.
Conversion to a format with a higher bit-depth can still result in data corruption due to aliasing sustained while resampling.
A 32-bit PNG is generally recommended as an ideal container.
void PxCrypt::StandardEncoder::setTag | ( | const QByteArray & | tag | ) |
Sets the encoding tag to tag.
Payloads are coupled with the tag during encoding in order to aid in payload identification or allow for the storage of any other string-based metadata. The tag is stored as part of the encrypted stream, not in plain text.
The tag is optional and can be left empty.