PxCrypt v0.2.2
Encrypt data within an image
Loading...
Searching...
No Matches
PxCrypt::Encoder Class Reference

The Encoder class is a base class from which all PxCrypt encoders derive in order to provide serialization of binary data to portions of an arbitrary image's color channels.

#include <>>

Inheritance diagram for PxCrypt::Encoder:
[legend]

Public Types

enum  Encoding : quint8 {
  Relative ,
  Absolute
}
 

Public Member Functions

virtual ~Encoder ()
 
quint8 bpc () const
 
Encoding encoding () const
 
QByteArray presharedKey () const
 
void setBpc (quint8 bpc)
 
void setEncoding (Encoding enc)
 
void setPresharedKey (const QByteArray &key)
 

Member Enumeration Documentation

◆ Encoding

This enum specifies the encoding strategy utilized when encoding/decoding data, which affects several aspects of the resultant image(s).

Relative

The input data is broken up into 1-7 bit-wide frames, according to the value selected for bits per channel, which are then woven into existing pixel data with each frame being mapped to one channel of a given pixel. This is accomplished by applying an offset to the original color channel value that matches the magnitude of the frame. The frame is subtracted from the original value if it is greater than 127; otherwise, the frame is added to the original value.

Because the data is not stored directly in the image, but rather as the difference between the original image and the encrypted image, the is no way to know what the offset for each channel was without a point of reference, and thus the original medium image is required in order to decode the encoded data. Payloads are more securely protected using this method.

The effect each frame has on a given channel is directly proportional to its magnitude, with higher value frames causing greater distortion in the original image. The best case scenario occurs when the frame has a value of zero, while the worst is when the frame contains the maximum value allowed by the BPC setting. Overall this means that the choice of medium has no effect on the amount of distortion and that the degree of distortion at a given BPC is influenced entirely by the input payload when using this strategy, with ideal data consisting largely of low bits.

Best Case) 0

Worst Case) 2N - 1 (where N = bits per channel)

Absolute

This is the default encoding strategy.

Input data is broken up into frames in the same manner as the Relative strategy, but are simply inserted directly into a pixel's channel data by replacing the lowest bits up to amount allowed by the BPC value. This allows the convenience of not requiring the original medium to decode the encrypted data, but at the cost of security since the output image relies entirely on the strength of the pre shared key for protection.

With this strategy the potential distortion caused by each frame depends on both the input data and the selected medium, as the degree of change is dictated by how different the frame is compared to the original bits that are being replaced. The best case scenario occurs when the frames data matches the original exactly, while the worst is when it is completely different. This leads to the same range of potential impact on the original image as with the Relative strategy, but in theory means that this method can out perform said strategy on average when the variance of the payload closes matches the variance of the image's color data

Best Case) 0

Worst Case) 2N - 1 (where N = bits per channel)

Enumerator
Relative 

Requires the original medium(s) in order to decode the encrypted data.

Absolute 

Does not require the original medium(s) in order to decode the encrypted data.

Constructor & Destructor Documentation

◆ ~Encoder()

PxCrypt::Encoder::~Encoder ( )
virtual

Destroys the encoder.

Member Function Documentation

◆ bpc()

quint8 PxCrypt::Encoder::bpc ( ) const

Returns the number of bits-per-channel the encoder is configured to use.

See also
setBpc().

◆ encoding()

Encoder::Encoding PxCrypt::Encoder::encoding ( ) const

Returns the encoding strategy the encoder is configured to use.

See also
setEncoding().

◆ presharedKey()

QByteArray PxCrypt::Encoder::presharedKey ( ) const

Returns the key the encoder is configured to use for data scrambling.

See also
setPresharedKey().

◆ setBpc()

void PxCrypt::Encoder::setBpc ( quint8 bpc)

Sets the number of bits-per-channel the encoder is configured to use to bpc.

This settings directly determines the number of bits woven into each color channel of a pixel and affects total encoding capacity. A BPC of 0 will instruct the encoder to determine the optimal BPC count automatically.

See also
bpc().

◆ setEncoding()

void PxCrypt::Encoder::setEncoding ( Encoding enc)

Sets the encoding strategy to use to enc.

See also
encoding() and Encoding.

◆ setPresharedKey()

void PxCrypt::Encoder::setPresharedKey ( const QByteArray & key)

Sets key used for scrambling the encoding sequence to key.

This key will be required in order to decode the resultant encoded data. An empty string results in the use of a known/default encoding sequence.

See also
presharedKey().

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