PxCrypt v0.1
Encrypt data within an image
Loading...
Searching...
No Matches
PxCrypt::Decoder Class Reference

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
 

Constructor & Destructor Documentation

◆ Decoder()

PxCrypt::Decoder::Decoder ( )

Constructs an encoder with an empty pre-shared key.

Member Function Documentation

◆ decode()

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().

See also
Encoder::encode().

◆ error()

DecodeError PxCrypt::Decoder::error ( ) const

Returns the error encountered while decoding, if any; otherwise, returns an invalid error.

See also
hasError() and reset().

◆ hasError()

bool PxCrypt::Decoder::hasError ( ) const

Returns true if decoding failed.

Use error() to retrieve the cause. Calls to decode() are ignored if the decoder's error state is set.

See also
reset().

◆ presharedKey()

QByteArray PxCrypt::Decoder::presharedKey ( ) const

Returns the key the decoder is configured to use for descrambling data.

See also
setPresharedKey().

◆ reset()

void PxCrypt::Decoder::reset ( )

Resets the error status of the decoder.

See also
error().

◆ setPresharedKey()

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.

See also
presharedKey().

◆ tag()

QString PxCrypt::Decoder::tag ( ) const

Returns the tag of the last successfully decoded payload.

See also
Encoder::setTag().

The documentation for this class was generated from the following files: