Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mekaem/recb
A tool to encrypt images with a block cipher in ECB mode that still shows the outline of the original
https://github.com/mekaem/recb
rust
Last synced: 6 days ago
JSON representation
A tool to encrypt images with a block cipher in ECB mode that still shows the outline of the original
- Host: GitHub
- URL: https://github.com/mekaem/recb
- Owner: mekaem
- License: mit
- Created: 2024-02-07T01:12:56.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-14T06:42:02.000Z (11 months ago)
- Last Synced: 2024-12-22T06:56:01.678Z (7 days ago)
- Topics: rust
- Language: Rust
- Homepage:
- Size: 1.25 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# recb
A tool to encrypt images with a block cipher in ECB mode that still shows the outline of the original.
When encrypting in ECB mode, identical plaintext blocks are encrypted into identical ciphertext blocks. Thus, if there are repetitive patterns in the original image data, these patterns might still be somewhat visible in the encrypted image because areas of the image that have the same color (and thus the same data representation) will look the same after encryption.# Usage
Install ImageMagick and make sure it's invokable from the command line.From the project directory:
```
cargo run path_to_image passphrase
```
The output quality will vary depending on two factors:
- The complexity of the source image (simpler images have better results). I find that the best results are from simple renders with transparent backgrounds, like the included Tux.png.
- The passphrase. Try different passphrases and see what happens!An image of Tux is included for historical & testing purposes.
# Source
The tool follows the following process:
```bash
# First convert the Tux to PPM
# Then take the header apart
head -n 4 Tux.ppm > header.txt
tail -n +5 Tux.ppm > body.bin
# Then encrypt with ECB (experiment with some different keys)
openssl enc -aes-128-ecb -nosalt -pass pass:"ANNA" -in body.bin -out body.ecb.bin
# And finally put the result together and convert to some better format
cat header.txt body.ecb.bin > Tux.ecb.ppm
```
by: [Filippo Valsorda](https://words.filippo.io/the-ecb-penguin/)