Skip to main content

A steganography library

Project description

hidebehind

License: LGPL v3 GitHub issues Code of Conduct

What is this?

It's a simple python library to embed data (files) into image/video/audio files.

Why?

It was written for educational purposes only. It may contain bugs, so use it at your own risk!

Installation

$ python3 -m pip install hidebehind

Quick start examples

First, read Unix philosophy:

Write programs to handle text streams, because that is a universal interface.

Assume you have:

$ echo "Dream big and dare to fail" > secret1.txt
$ echo "Talk is cheap. Show me the code." > secret2.txt
$ wget https://github.com/multifrench/hidebehind/blob/main/img/Gauss.png

Then:

$ hide put -c Gauss.png < secret1.txt > embedded.png
$ hide get < embedded.png > s1-restored.txt
$ cat s1-restored.txt

Encryption

It's not safe to transmit unencrypted (sensitive) information over public connections.
In this example I'll use GnuPG, but you can use anything you want (i.e. VeraCrypt)

# Encrypt:
$ gpg -er <YouKeyID> -o - < secret2.txt | hide put -c Gauss.png > embedded.png
# Decrypt:
$ hide get < embedded.png | gpg -d > s2-restored.txt
$ cat s2-restored.txt

Multiple files & compression

In case you want to transmit more than one file at once, use tar.
It's also a good idea to compress our data. I'll use bzip2.

$ tar -c secret?.txt | bzip2 -9 | hide put -c Gauss.png > embedded.png
# And get our data back:
$ hide get < embedded.png | tar -xj
$ cat secret?.txt

Integrity

In addition, to be sure our files weren't corrupted, we will write down their hashes (sha256sum) into a separate file and use technique from the previous paragraph to save them.

$ sha256sum secret?.txt > .shasum
# Copy-paste the previous code block but add `.shasum` into the archive.
$ tar -c secret?.txt .shasum | bzip2 -9 | hide put -c Gauss.png > embedded.png
# Get our data back:
$ hide get < embedded.png | tar -xj
# Now, verify the data wasn't corrupted (or it was)
$ sha256sum -c .shasum

What else?

Write programs to handle text streams, because that is a universal interface.

Remember? I hope now you're (if you weren't) convinced it's very useful technique. You may, for example, want to embed encrypted and compressed secret and then check its integrity. It's up to you.

How does it work?

Do you see the difference?

A square The square with embedded message in it

Nor do I. But there is a secret embedded in it!

Stay hungry. Stay foolish

Basically, the idea behind it is that the human eye is very insensitive. It can't detect difference in less than 1%.
The program slightly changes the value of blue part (of an RGB pixel).

Implementation detail Assume we want to hide a sequence of bytes S (that's our secret message; it's not necessarily a string of printable characters, i.e. a binary file) into an image I. For simplicity, we assume an image is an NxMx3 array, where I[i][j] is [red, green, blue]. We are only interested in 0 <= blue < 256 value. It's possible to represent it as a binary number. For example, 55 = 0b110111. If we clear last least significant bit, we get 0b110110 = 54. We changed the value of it only by less than 0.4%! Having done so, now we can store the payload there. Yes, a bit of the payload goes into one pixel. If we want to embed more, we modify two least significant bits. The maximum difference then will be 1.2%, but it's still OK.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hidebehind-0.0.2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

hidebehind-0.0.2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file hidebehind-0.0.2.tar.gz.

File metadata

  • Download URL: hidebehind-0.0.2.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for hidebehind-0.0.2.tar.gz
Algorithm Hash digest
SHA256 371138f2a20f45c8b8daf401f64764ffed55a3018f13ce98be5f1b35b1517638
MD5 f6641eebe683c54bbd4ef00e925b316e
BLAKE2b-256 e279191ed2a046529351056bf7ec8f02c38aacf13db0580376dfc53e562f5dfa

See more details on using hashes here.

File details

Details for the file hidebehind-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: hidebehind-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for hidebehind-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bb11ff5e418167400de2708be3e9d9d35e52ac3a35e9b39b033c89e11e426b5f
MD5 eea34ea33a674a60ee9e70e6a22ac5b5
BLAKE2b-256 493b28e70e4651e0cd66d0f2e61e504ec88bc8ab595c98434a0ed494eadfe9ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page