Introduction

PIE (Pixel Image Encoder) 

FREE  lightweight library for encoding and encrypting files or text. This library can be used within your existing software, used on a command line using a console or within script files.

History

The original project was to build a new compression system for files or text using image pixels, algorithms, and existing compression methods. The project aimed to offset each byte from the original file into a colour profile. This means you can put 4 (compressed) bytes to every pixel. 

This had some promising success, and in most cases could compress files (even if already compressed) down an extra 10%, but more RND and formulas were needed.

From this project came "PIE". PIE can store sensitive "Text" or "Files" securely which can then be sent (using your own software) to a private or public destination. There it can be decoded / decrypted using methods within PIE with no other 3rd party libraries.

The source code and library will be freely available to download for anyone who thinks this might be useful, but as this software is still being tested, please contact pixel.image.encode@gmail.com for further information.

Specification

  • Written in Java
    The library has no dependencies and is coded in pure Java. This makes it easer to convert in to other programming languages and import into any project and any version of Java to date.
  • Cross platform
    The library will work on Windows, MacOS, Linux, or any other operating system that can run Java or its conversions.
  • Portable
    The library can be run from a command line - only a reference to a JRE is required. Java does not need to be installed, the software can be run from a copy of Java in a folder even if its on a USB Drive.
  • Lightweight
    The Jar file can be used in any Java application (Java 8+).
  • Secure
    Messages are very secure. Without the correct software, settings, certificates, or phrases, decoding and decrypting the messages would be extremely difficult to impossible (depending on the options used). See "Encryption" for more information.
  • Programmable Herd Immunity
    Encoded files have "Programmable Herd Immunity". This means another program cannot distinguish the encoded file from any other file of the same type even if it is loaded and analysed. The file will also behave exactly like the intended file type. For example, the encoded file will load and can be used in any paint or photoshop application. The file can also be used in web pages stored in Word documents, PDFs, etc.
  • Encryption
    Encryption is optional but can be included when required.
  • Versatile
    Any file from any operating system can be encoded, not just Text and Documents.

Translations

A small translation system is included with four built in languages: English, French, Italian, and Spanish. More can be added if required. The library will detect what language is being used and any messages will be shown in that language. The default is English. Some options are also translatable.

Versions

Supports java 8 all the way to the latest version.

For Java version 6 / 7 please contact the author at pixel.image.encode@gmail.com

To download PIE please visit the download page.

Using as a command in terminal

To download Java, click " Download" or visit our download page for Java version 8+. 

When using Java, the PIE library only needs access to a JRE / JDK not necessarily an installed version. If you have java installed you can run the commands immediately. 

If you don't have Java installed, you only need the runtime. Download a copy of Java without installing. Extract the contents to a folder. Then use the path to the "bin" folder, for example "./jre/bin/java".

If you want a portable version and you have Java installed, locate the Java install directory. Copy the JRE. Place the copied folder to wherever you need it. You can then use this to run PIE as a command or from scripts, from anywhere you like, and distribute it.

The source code for all versions will be available in the future and downloadable on GitHub. Keep checking this blog for more information.

How it works

While encoding, the source file or text is completely broken down into bytes and reassembled into an image pixel by pixel. Each pixel is split into 4, compressed, encoded, and encrypted (depending on the users options). Different compression methods are also used to make sure the size is either the same or less than the original version of the file. If the original file already uses compression, there may not be a difference.

The result is no different than any other image, including metadata, and can be saved directly to the hard drive or used via a bufferedimage. The library can also serve the image as a converted byte array.

When decoded and decrypted, the file and metadata will be intact. If decoding text, options are available for automatic detection and use.

The library will encode files up to 600mb (depending on the options), however if the file is larger, the file will be broken down into sections. A zip file will be created and each part will be added to the zip.  Note: this restriction can be changed using options.

To decode, you only need to supply the image or a zip file that has been previously encoded. Full examples are included for using within your code and command line usage.  

Encoding Example

3531 x3531 to

In this example the "tomato.png" was 3531px x 3531px and the file size was 1.94MB. After encoding and encrypting, the encoded image was 890px x 570px and the file size was 1.91MB. The original file was already compressed. 

Visually the encoded file looks like a broken or corrupt image. But programmatically, its just an image, perfect for hiding online. However the encoded file can be fully transparent.

Practical Usages

There are numinous usages for this library. However only a few have been listed.

  • Hiding files on a hard drive, external drives, or online
    Files can be hidden in plain sight, online, and decoded when required. Take a close look at the headers in this section! When sending a message, anyone looking to find out what you've sent would need to download every image, visually inspect each one, then try and crack the message (which could take decades even with the library). Plus, what if you put decoy images in!

  • Protecting files online
    When uploading sensitive files online like images, documents, etc, no matter the security, online hackers will find a way of getting it. With AI now trawling the internet looking for training material, your data could be stolen and used for AI purposes or worse. Using PIE could stop this and protect/encrypt your online data.

  • Sending Text either via Chat or email
    The original purpose of the library was to send encrypted text in a way so that agencies, IP, etc, would not be able to see it or decode it. As the message is an image and trillions of images are passed via communications every day, these images would not be detected, and even if they were, the process of hacking them would be so huge it would not be worth it.

    Text would be encoded and encrypted into an image then sent directly via email, FTP, HTTPS, etc The recipient would then decode and decrypt the image and no one would be any the wiser. See "encryption" and "decryption" for more details. You could write software to do the entire process of encoding and decoding so only your friends, customers, etc, could get the information. 

  • Copyright tagging
    One of the encoding modes available is to make the encoded image completely transparent. This means you can encode and encrypt some text for a file and hide it inside a PDF, a document, within software, or anything that allows a file. The image would not be viewable and therefore if it comes to a lawsuit or something the file can be extracted and decoded and decrypted. Showing your copyright data or whatever you like.

Encoding Modes

Two encoding modes.

  • Mode 1
    Fully Transparent. Generates a fully transparent image. The only downside is the file size might be a little higher than the original but not by much.

  • Mode 2
    Semi Transparent. This means you will see pixels but will be Semi Transparent. This should be lower then original file size, however if the file is already compressed you might not see any difference.

More modes will be available in the future.

Encryption

Encryption is optional and depends on your project, If you do want to use encryption you have 2 options

  • Option 1
    Use a passphrase of any length directly into the library for both encoding and decoding.

  • Option 2
    You can generate a PIE Certificate. It's easy to do this and there are full instructions with a step by step guide. When a certificate is generated you have to pass this into the library for both encoding and decoding. Just make sure your clients have the same certificate and that's it. You can start distribution.

When using a certificate no one knows the key. Only those who have a copy of the certificate can encode and decode the files. The certificate is make up of 700 - 1000 random bytes, from 0 to 255 bytes. to put this into perspective.

To brute force the password the number of possibilities with each character being a byte (0-255), there are 256 possibilities for each of the 1000 characters. This translates to a staggering 256 ^ 1000 possible combinations. 

If a computer can check one billion combinations per second (an extremely high hypothetical number), it would take roughly 2^86 seconds to check all possibilities. Dividing that by the number of seconds in a year (roughly 3.15 x 10^7), we get approximately 2^79 years. This is an unimaginable timeframe. 

Taking this into consideration and the certificate is not human readable, the certificate is also wrapped using the PIE library and encoded into an image which ties everything up. When using the certificate the library decodes the image and uses the extracted characters as the key with additional information set at the time of encoding.



This Blog is intended to help anyone write their own encoding system using PIE using the jar file and source code, hopefully others can improve on what has been built.

As with all free software available on the internet and even some paid versions please note the disclaimer / License Agreement. You use this software at your own risk. This software is free to use, change and distribute for all commercial and personal use projects