PxCrypt v0.1
Encrypt data within an image
|
The Decoder class provides the means to skim and decrypt data from the color channels of an encoded image.
#include <>>
Public Member Functions | |
Decoder () | |
QByteArray | decode (const QImage &encoded, const QImage &medium=QImage()) |
DecodeError | error () const |
bool | hasError () const |
QByteArray | presharedKey () const |
void | reset () |
void | setPresharedKey (const QByteArray &key) |
QString | tag () const |
PxCrypt::Decoder::Decoder | ( | ) |
Constructs an encoder with an empty pre-shared key.
QByteArray PxCrypt::Decoder::decode | ( | const QImage & | encoded, |
const QImage & | medium = QImage() |
||
) |
Retrieves data from the encoded PxCrypt image encoded and returns it as a byte array.
The original medium image medium is used as a reference for images with encodings that require it, but is otherwise ignored. The encoded data is descrambled using the currently set pre-shared key.
If encoding fails, a null byte array will be returned. Use error() to determine the cause. Further attempts to use decode() will be ignored until the error state is cleared via reset(). After an image is successfully decoded the tag of the encoded data is made available via tag().
DecodeError PxCrypt::Decoder::error | ( | ) | const |
Returns the error encountered while decoding, if any; otherwise, returns an invalid error.
bool PxCrypt::Decoder::hasError | ( | ) | const |
QByteArray PxCrypt::Decoder::presharedKey | ( | ) | const |
Returns the key the decoder is configured to use for descrambling data.
void PxCrypt::Decoder::reset | ( | ) |
Resets the error status of the decoder.
void PxCrypt::Decoder::setPresharedKey | ( | const QByteArray & | key | ) |
Sets key used for descrambling the encoding data to key.
This key must be the same that was used when the data was encoded. An empty string results in the use of a known/default decoding sequence.
QString PxCrypt::Decoder::tag | ( | ) | const |
Returns the tag of the last successfully decoded payload.