ImageCrypt

Project description

Project AlexGyver on Python by Pend0s

Design by Пашушка


Byte packing in decimal rgb:

this_color = b * 65536 + g * 256 + r
this_char = ord(char)

new_color = (this_color & 0xF80000)       # 11111000 00000000 00000000
new_color |= (this_char & 0xE0) << 11     # 00000111 00000000 00000000
new_color |= (this_color & (0x3F << 10))  # 00000000 11111100 00000000
new_color |= (this_char & 0x18) << 5      # 00000000 00000011 00000000
new_color |= (this_color & (0x1F << 3))   # 00000000 00000000 11111000
new_color |= (this_char & 0x7)            # 00000000 00000000 00000111

Unpacking byte:

new_color = b * 65536 + g * 256 + r

this_char = 0
this_char |= (new_color & 0x70000) >> 11  # 00000111 00000000 00000000 -> 00000000 00000000 11100000
this_char |= (new_color & 0x300) >> 5     # 00000000 00000011 00000000 -> 00000000 00000000 00011000
this_char |= (new_color & 0x7)


Method for russian symbols:

# Encryption
if this_char > 1000:
    this_char -= 890

# Decryption
if this_char > 130:
    this_char += 890

Installation:

Clone repository, install virtual environment and installing dependencies:

git clone https://github.com/Pendosv/ImageCrypt.git
cd ImageCrypt
virtualenv venv
source venv\Scripts\activate
python3 -m pip install -r requirements.txt
chmod +x image-crypt
sudo ln -s $PWD/image-crypt /usr/bin/image-crypt

Usage

GUI:

python3 main.py
Example

Bash:

image-crypt --help

Result:

usage: image-crypt [-h] (-e | -d) [-o OUTPUT] images [images ...]

Stenography encryption tool

positional arguments:
  images                path to image to encrypt of decrypt

optional arguments:
  -h, --help            show this help message and exit
  -e, --encrypt         encrypts text in image
  -d, --decrypt         decrypts text from image
  -o OUTPUT, --output OUTPUT
                        name of output image


For encryption:

image-crypt -e images/test.jpg

Result: saved image with default name image_encrypted.bmp

For decryption:

image-crypt -d test_encrypted.bmp

Result: decrypted text


Example:

echo "test message" | image-crypt -e image.png -o test_image.bmp

image-crypt -d test_image.bmp > res.txt

GitHub

GitHub - Pendosv/ImageCrypt: Text-to-image encryption script
Text-to-image encryption script. Contribute to Pendosv/ImageCrypt development by creating an account on GitHub.