PxCrypt v0.2.2
Encrypt data within an image
|
The MultiEncoder class encodes a payload and identifying tag into a single image.
#include <>>
Classes | |
class | Error |
The MultiEncoder::Error class is used to report errors during multi-image encoding. More... | |
Public Member Functions | |
MultiEncoder () | |
Error | encode (QList< QImage > &encoded, QByteArrayView payload, const QList< QImage > &mediums) |
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 QList< QSize > &dims, quint16 tagSize, quint8 bpc) |
static quint8 | calculateOptimalDensity (const QList< QSize > &dims, quint16 tagSize, quint32 payloadSize) |
Additional Inherited Members | |
![]() | |
enum | Encoding : quint8 { Relative , Absolute } |
PxCrypt::MultiEncoder::MultiEncoder | ( | ) |
Constructs an encoder with default settings:
|
static |
Returns the maximum number of payload bytes that can be stored within a images of dimensions dims 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 medium images of dims 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.
Error PxCrypt::MultiEncoder::encode | ( | QList< QImage > & | encoded, |
QByteArrayView | payload, | ||
const QList< QImage > & | mediums ) |
NOTE: Note how the order of the parts wont necessarily be the same as mediums
Encodes payload within the medium image medium and stores the result in encoded, then returns an error status.
Encodes payload within the images from mediums, distributed proportionally according to their dimmensions. That is, the bytes of the original payload are split into chunks and spread across all medium images.
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 each medium is determined independently based on the size of payload. Usually the ideal BPC is the same for all mediums, but there are some edge cases where some might differ from the rest by +/- 1
. The encoders BPC will be set to the highest BPC used in this case.
The encoded images will always use the format QImage::Format_ARGB32
or QImage::Format_RGB32
(depending on if the original has an alpha channel) regardless of the format of the original medium.
The images produced by this function must never undergo a reduction in fidelity in order to remain decodable. In other words, they 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 alpha channels so they 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::MultiEncoder::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.