-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thick Wrappers #9
Open
janine9vn
wants to merge
227
commits into
main
Choose a base branch
from
thick-wrappers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
227 commits
Select commit
Hold shift + click to select a range
4d5dc75
Initial commit
DavidLlanio 6bc8fd6
Updated Python Version lint.yaml
DavidLlanio e89adcb
Update README.md
DavidLlanio 06f09fd
Merge pull request #1 from DavidLlanio/sample
DavidLlanio 4b7cd52
init
maxence-glt abfd798
static file added
maxence-glt 8956904
samples deleted
maxence-glt d39f289
Merge pull request #2 from DavidLlanio/decrypt_text
maxence-glt 6cf1aa2
pre-commit lint
DavidLlanio 05cc2b7
Merge pull request #3 from DavidLlanio/decrypt_text
DavidLlanio 062f8c5
Fixed Linting Sheesh
DavidLlanio 1133a76
Merge pull request #4 from DavidLlanio/decrypt_text
DavidLlanio 68285cc
Created general layout of GUI, Added pydis_logo
DavidLlanio 46f8138
Added nicegui to requirements
DavidLlanio da38897
Images can be uploaded and stored in static folder
DavidLlanio 97e8820
Encryption function
77e5a27
Placeholders for encryption and decryption events
DavidLlanio 4e94039
Created function that take binary in and spits out the ascii version
maxence-glt 7c874bd
Merge pull request #5 from DavidLlanio/binary_to_ascii
maxence-glt 7f8341d
Revise pixel selection
bc4b752
Add message padding
78472dd
pixel to hex func finished
maxence-glt b657b38
Added Pillow to requirements
DavidLlanio 8336ee2
Created encrypt callback for encrypt button
DavidLlanio 3db5ca0
Function to convert pixel to binary
maxence-glt 4863afd
Text decyption layed out
maxence-glt 219e047
Fix byte conversion bug
9ebaa16
FInxed linter
maxence-glt 82b78f8
Merge pull request #7 from DavidLlanio/linting-testing
maxence-glt 74155f2
Changed copyright statement
DavidLlanio 7d025df
Update LICENSE (mispelt my username)
maxence-glt 50262fc
decrypt callback function and file path mods
DavidLlanio 8e3d6df
Created dataclass to keep track of file paths
DavidLlanio b86a0c5
image to image initial implementation
Jaavv e214c88
Callback functions use filepaths class object
DavidLlanio 9c88c85
Updated decryption callback function docs
DavidLlanio e387e34
Small correction on if statement
DavidLlanio 274fec9
Merge branch 'stega' into dev
Jaavv 69319b9
Merge pull request #8 from DavidLlanio/stega
Jaavv c144da3
Static folder discoverable by GUI
DavidLlanio 5bc9093
Modified all_pixels_to_binary funciton to allow for Pillow objects to…
maxence-glt cea5dbd
Merge branch 'main' into decryption
maxence-glt 58f35dd
Merge pull request #9 from DavidLlanio/decryption
maxence-glt 421c409
GUI now pops up output with option to download
DavidLlanio f60ba8f
Merge remote-tracking branch 'main/dev' into gui
DavidLlanio 367119a
Merge pull request #10 from DavidLlanio/gui
DavidLlanio 4a58371
Merge remote-tracking branch 'origin/dev' into dev
Jaavv 01e400c
added Pixel class
Jaavv fc65405
added get_rgb methods
Jaavv d8963a9
added typing to methods and override toString
Jaavv 4a5cebf
Add file to test encryption/decryption, and sample image
e7ae25a
Decryption function FINISHED. Need to add lexicon
maxence-glt 3a66296
Flake8 check passed
maxence-glt d7226bf
Merge pull request #11 from DavidLlanio/decypt_text
maxence-glt 17cdd0a
StegaImage refactor
Jaavv de7be21
Removed print examples
maxence-glt bbd21d4
stega tweaks
Jaavv ba54cc6
Copy image and strip input text
d8d91e8
Removed string fabricators
maxence-glt 25a6a33
Removed redundant string fabricators
maxence-glt e86c1da
Merge branch 'dev' of https://github.com/DavidLlanio/cj10_the_thick_w…
Jaavv 837d9fe
Merge pull request #6 from DavidLlanio/encrypt-text
DavidLlanio ba3194a
Merge branch 'main' of https://github.com/DavidLlanio/cj10_the_thick_…
DavidLlanio 74e8108
Remove testing image
3d8f133
Add function to decrypt secret image
Robin5605 1579828
Lint
Robin5605 9e6960d
Merge pull request #12 from DavidLlanio/decrypt-image
DavidLlanio 7fa0d4d
Sample pictures
DavidLlanio 149676a
Changed print pos
maxence-glt c46547f
Added encrypt text function
DavidLlanio 99ffd28
Fix row-column order
6ca7af2
Merge branch 'main' of https://github.com/DavidLlanio/cj10_the_thick_…
DavidLlanio 55ef6f6
Actually fix column-row bug
7ecbcfc
Merge branch 'main' of https://github.com/DavidLlanio/cj10_the_thick_…
DavidLlanio 2203629
Remove breakpoint
388cc7a
Forcing all image files to be in png format
DavidLlanio 0ae1926
Merge pull request #13 from DavidLlanio/gui
DavidLlanio 33cbac9
added Pixel class to accept tuple args
Jaavv 59d58b7
RGB -> BGR
maxence-glt 7acd803
Merge branch 'dev' of https://github.com/DavidLlanio/cj10_the_thick_w…
maxence-glt a76a89f
Merge branch 'main' of https://github.com/DavidLlanio/cj10_the_thick_…
maxence-glt 027e71a
Stega image fixes
Jaavv 588f34a
Merge remote-tracking branch 'origin/dev' into dev
Jaavv 7af78dc
Stega image tweaks
Jaavv e7a858c
added Steganograpizer class
Jaavv ed0abf9
added numpy for dependency
Jaavv cc5d000
added Steganographizer class
Jaavv 1517145
minor tweaks
Jaavv 60754a1
added encrypted image
Jaavv c752b0f
Binary decoder almost complete
maxence-glt f081dfd
Delimiter
maxence-glt 4baac58
implemented Steganographizer to GUI
Jaavv 6c57c4f
Gitignore updated
maxence-glt 3e7711c
Merge branch 'dev' of https://github.com/DavidLlanio/cj10_the_thick_w…
maxence-glt 9fdef1e
Added text decryption to GUI, removed textdownload
DavidLlanio b15caf2
Merge branch 'dev' of https://github.com/DavidLlanio/cj10_the_thick_w…
DavidLlanio a757adb
Modified binary_decoder to output text and flag
DavidLlanio df5ce00
Changed output text
DavidLlanio 797a787
gitignore update
maxence-glt 834a6f7
Refactored much of text decryption
maxence-glt 4b92d12
Removed print statement
DavidLlanio 9ed2d40
Merge branch 'dev' of https://github.com/DavidLlanio/cj10_the_thick_w…
DavidLlanio dbbf2a3
gitignore whole static folder fix
Jaavv e0454f0
StegaImage refactor
Jaavv 04609f1
StegaImage refactor
Jaavv ce4410c
rename to proper method
Jaavv e94b04e
Steganographizer refactor
Jaavv 5d4eacb
Don't assume 24-bit depth images
Robin5605 c152e17
Actually call decrypt_image from UI
Robin5605 5fed358
Steganographizer refactor to static method
Jaavv 444f438
tweaks
Jaavv ab8e366
minor comment update
Jaavv da88f16
minor tweaks
Jaavv 88f9d6e
docstring update
Jaavv ae511ed
encrypt_image static method change
Jaavv dc07f71
Initial text upload version
df9e6d0
Merge branch 'dev' of https://github.com/DavidLlanio/cj10_the_thick_w…
DavidLlanio 90f6e89
Merge pull request #14 from DavidLlanio/decrypt-image
DavidLlanio 31ab671
Merge branch 'dev' of https://github.com/DavidLlanio/cj10_the_thick_w…
DavidLlanio 814c1f4
Update README.md
maxence-glt 72ba881
Fixed bug output image wouldn't save
DavidLlanio 9085426
Shortened convert_pixels_to_binary function
maxence-glt 02269f7
Merge branch 'dev' of https://github.com/DavidLlanio/cj10_the_thick_w…
maxence-glt a38c9e0
decrypt and encrypt functions started
maxence-glt b8f3479
Added refactor files with function signatures
DavidLlanio 183653d
Merge branch 'dev' of https://github.com/DavidLlanio/cj10_the_thick_w…
DavidLlanio 4713251
Merge pull request #17 from DavidLlanio/text-upload
DavidLlanio 1b734ab
Added text decrypter to decrypt.py
maxence-glt 979c2bd
Added pixel iterator to utility
maxence-glt 70f87fa
Changed funciton calls to match new files
maxence-glt 7f3f86d
Removed redunant file
maxence-glt 5306cf1
Hint typing and linter approved
maxence-glt ea1d126
Hint typing and changed import specifics
maxence-glt f267281
deleted pixel and image_to_image file
Jaavv 1e2e354
Revise tests
3cb2ef8
added exif dataclass
Jaavv 31033ef
Add exception handlers for invalid image and text files
cf7cf3e
Add decrypt handler
24fbe20
Revise exceptions
21620d1
apl_info fixes
Jaavv 875fd2c
added functions:
Jaavv b9063b9
encrypt_image_to_image function update
Jaavv 60a3231
ratio fixes
Jaavv ff7ae24
update_image method fix
Jaavv ebb8f1c
import cleanup
Jaavv 66da1fe
Merge pull request #19 from DavidLlanio/image_handler
DavidLlanio 6d0c222
GUI does not resize images anymore
DavidLlanio c43bb02
Fixed relative import
DavidLlanio 51df3b3
Merge pull request #20 from DavidLlanio/gui
DavidLlanio 1bdd407
Merge pull request #18 from DavidLlanio/numpy-encrypt
DavidLlanio 18ff9d5
Merge pull request #21 from DavidLlanio/numpy-encrypt
77b0cf5
resize_image implementation
Jaavv 30d2696
encrypt_image_to_image function fix
Jaavv fc34a31
resize_image logic tweaks and embed_exif docstring update
Jaavv 1892f0c
resize_image magic number fix
Jaavv 8734f9e
lsb and msb function docstring update
Jaavv 9237514
Fix encryption bug, optimize string encoding
bb76a4b
added file to store constant values
Jaavv 4db53c7
added for package fixes
Jaavv 28986f2
Basic styling
DavidLlanio 026417d
delete unused files
Jaavv b8e51f9
image encryption function fixes
Jaavv 2c3e4db
shift_image_bits_asarray function added, exif function fix, resize_im…
Jaavv 75f9861
updated bit shift function
Jaavv 1ca136e
minor tweaks
Jaavv 6382a5e
Move image decryption into decrypt.py
Robin5605 cd1b417
Invoke moved function from main
Robin5605 3282d26
exif_embed_apl function rename
Jaavv e4c6475
exif_embed_apl function rename;
Jaavv b76adca
Test commit, added numpy to decrypt.py
maxence-glt 20bf4f0
Removed placeholder funciton
DavidLlanio 5e07cec
Merge pull request #22 from DavidLlanio/decrypt-image
DavidLlanio a18bd3d
Software Title Fix
Jaavv 11fe9ca
exif Make Fix
Jaavv fadb5a2
module fix
Jaavv 371b379
changed Image to array arg type
Jaavv a72130f
shift_image_bits_array image param change to array type; exif_model_b…
Jaavv 6792758
ipp typo fix
Jaavv 0cb685a
ipp typo fix
Jaavv 423b6d1
Merge branch 'enc_image' into dev_jaavv_copy
Jaavv 044093d
Dark mode added
DavidLlanio 571f5d2
module fix
Jaavv f9b68f0
encrypt_image_to_image fix
Jaavv 15f113d
resizing hotfix
Jaavv 3dd24aa
Update
maxence-glt ce28fe0
Merge pull request #24 from DavidLlanio/gui
DavidLlanio 5296717
Update tests
2895292
Improve docstrings
98c0eef
Updated README
DavidLlanio 623f63b
Merge branch 'dev' into refactor-text
DavidLlanio cf7f483
Merge pull request #25 from DavidLlanio/refactor-text
DavidLlanio 37b3a8f
Merge pull request #26 from DavidLlanio/gui
DavidLlanio 7b81d18
wip: parse image size from exif
Robin5605 59ad152
Linting
DavidLlanio c899265
Removed regex package and global
DavidLlanio 16ec150
Replaced function import with refactored function
DavidLlanio b6ec63e
Gracefully handle missing EXIF data
Robin5605 979b6cd
Fixed issure with text file upload
DavidLlanio ced3348
Merge branch 'dev' into decrypt-image
Robin5605 3fe3ba9
Merge pull request #27 from DavidLlanio/decrypt-image
Robin5605 194db8f
Linting
DavidLlanio e2e4db6
More linting
DavidLlanio f0025e9
Handle RGBA images
053ea16
Removed images from static
DavidLlanio 0f27657
Merge branch 'main' into dev
DavidLlanio 431fc1b
Linted gitignore
DavidLlanio 81beb44
Merge branch 'dev' of https://github.com/DavidLlanio/cj10_the_thick_w…
DavidLlanio 948b13d
Import changes to pass linting
DavidLlanio 434b45c
Merge pull request #29 from DavidLlanio/dev
DavidLlanio c1f7d02
Merge branch 'dev' into fix-rgb
e1e0929
Merge pull request #30 from DavidLlanio/fix-rgb
6de4852
Update README.md
maxence-glt 11f6669
Update decrypt.py
maxence-glt abf023b
Set up image tests, fix docstrings
0c28650
Improve project docstrings
7f24c47
Test unprintable chars
cba3fc0
Add file deletion
6d8a378
Flush on illegal file uploads
230b440
Merge pull request #31 from DavidLlanio/image-test
d19537a
Merge pull request #32 from DavidLlanio/file-delete
0b158ca
Fix test error
282842e
Merge pull request #33 from DavidLlanio/fix-tests
f694a8e
Merge pull request #34 from DavidLlanio/dev
4ba8021
Added GUI GIF to README
DavidLlanio 73874ea
Fixed Link in README GIF
DavidLlanio a1a1bca
Fix formatting on GIF
DavidLlanio 6211ec6
Add 'thick-wrappers/' from commit 'a1a1bca09fcb5b9fbce4d6c225001a271c…
janine9vn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# GitHub Action Workflow enforcing our code style. | ||
|
||
name: Lint | ||
|
||
# Trigger the workflow on both push (to the main repository, on the main branch) | ||
# and pull requests (against the main repository, but from any repo, from any branch). | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
# Brand new concurrency setting! This ensures that not more than one run can be triggered for the same commit. | ||
# It is useful for pull requests coming from the main repository since both triggers will match. | ||
concurrency: lint-${{ github.sha }} | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
# The Python version your project uses. Feel free to change this if required. | ||
PYTHON_VERSION: "3.11" | ||
|
||
steps: | ||
# Checks out the repository in the current folder. | ||
- name: Checks out repository | ||
uses: actions/checkout@v3 | ||
|
||
# Set up the right version of Python | ||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Run pre-commit hooks | ||
uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Files generated by the interpreter | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# Environment specific | ||
.venv | ||
venv | ||
.env | ||
env | ||
|
||
# Unittest reports | ||
.coverage* | ||
|
||
# Logs | ||
*.log | ||
|
||
# PyEnv version selector | ||
.python-version | ||
|
||
# Built objects | ||
*.so | ||
dist/ | ||
build/ | ||
|
||
# IDEs | ||
# PyCharm | ||
.idea/ | ||
# VSCode | ||
.vscode/ | ||
# MacOS | ||
.DS_Store | ||
|
||
# Custom | ||
.test_folder | ||
|
||
# Image folder | ||
static/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## Pre-commit setup | ||
# See https://github.com/python-discord/code-jam-template/tree/main#pre-commit-run-linting-before-committing | ||
|
||
# Make sure to edit the `additional_dependencies` list if you want to add plugins | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.5.0 | ||
hooks: | ||
- id: check-toml | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
args: [--markdown-linebreak-ext=md] | ||
|
||
- repo: https://github.com/pre-commit/pygrep-hooks | ||
rev: v1.5.1 | ||
hooks: | ||
- id: python-check-blanket-noqa | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: https://github.com/pycqa/flake8 | ||
rev: 4.0.1 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: | ||
- flake8-docstrings~=1.6.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2023 The Thick Wrappers(DavidLlanio, maxence-glt, jaavv, standard-affect, Robin5605) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# In Plain Pixel | ||
Created by "The Thick Wrappers" (github: DavidLlanio, maxence-glt, standard-affect, Jaavv, Robin5605) for the Python Discord 2023 CodeJam | ||
|
||
## In Brief | ||
In Plain Pixel is a Steganogrpahy application built completely with Python. Through this application, you are able to encrypt a valid input method (see below) into an image of your choice, or decrypt an image created through this application by simply inputting your decrypted image. | ||
|
||
The following input types are supported for encryption: | ||
- Typed Text | ||
- Text File (*.txt) | ||
- Image File (*.jpg, *.jpeg, *.png) | ||
|
||
## What is Steganography? | ||
Imagine you want to pass a note to your friend in a crowded library, but don't want to draw attention to the contents of the note or the note itself. Maybe you hide the message you want to pass in something inconspicuous like in the margins of a book or between the lines of sentences. In essence, you're hiding your message in plain sight. | ||
|
||
[Steganography](https://en.wikipedia.org/wiki/Steganography) is similar to this concept, but with digital media, like pictures! | ||
|
||
With steganography, you can hide something like a text message in a picture. You can even hide a picture in another picture! | ||
|
||
### How does it work? | ||
|
||
Computers only understand ones and zeros. Let's say a pixel in an RGB digital image has the integer values of [255, 255, 255], representing white. | ||
|
||
255 in binary is 11111111 | ||
So the entire pixel is: [11111111, 11111111, 11111111] | ||
|
||
With steganography, you can hide something in the [least significant bits](https://www.analog.com/en/design-center/glossary/lsb.html#:~:text=Least%2Dsignificant%20bit.,is%20the%20furthest%2Dright%20bit.) of this pixel. For example, let's hide the letter "H" in this pixel. | ||
|
||
The [ASCII](https://www.asciitable.com/) code of the letter "H" is: 72 (decimal) or 1001000 (binary) | ||
|
||
We can split up the binary of the ASCII for "H" into 3 parts: | ||
- 1 | ||
- 001 | ||
- 000 | ||
|
||
Then clear and set the least significant bits of the pixel RGB values: | ||
- R: 11111111 -> 11111000 | ||
- G: 11111111 -> 11111001 | ||
- B: 11111111 -> 11111111 (Last bit stays the same) | ||
|
||
With these changes, the letter "H" is now hidden in the image with little impact to the image itself. | ||
|
||
### How are we using Steganography? | ||
The previous example features our method of hiding text in an image. We split the character's binary into 3 parts and hide the most significant bit in the lease significant bit of the blue channel, the 3 middle bits in the 3 least significant bits of the green channel, and the 3 least significant bits in the 3 least significant bits of the red channel. | ||
|
||
We do this process for every character in the word, sentence, or paragraph. | ||
|
||
For image inputs, we place the 4 most significant bits of the RGB channels of every pixel of the image you want to hide into the 4 least significant bits of the RGB channels of every pixel of the image you want to use as the cover. | ||
|
||
When you decrypt an image inside of another image, you will get a lower quality version of the original image you wanted to hide because we cannot reproduce the least significant bits of the original image. | ||
|
||
## How to Set up | ||
- Download and unzip the repository, or clone it | ||
- Use the change directory command into the repository at the level of main.py | ||
``` | ||
cd cj10_the_thick_wrappers | ||
``` | ||
- Install the dependencies: | ||
``` | ||
python3 -m pip install -r dev-requirements.txt | ||
``` | ||
## How to Start and Use GUI | ||
After setup, run the main.py file to start the GUI: | ||
``` | ||
python3 main.py | ||
``` | ||
|
||
Sample use of GUI: | ||
|
||
Encrypting text into an image | ||
|
||
![In Plain Pixel](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExenhtZHU1cGp2MmExZnk4NmZqcHV0ZHhmNHQ2ZWFsNWozdmFzbGJ4OCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/O7yq741e0EFZ4lLxpW/giphy.gif) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pytest | ||
|
||
from helper.utility import list_images | ||
|
||
|
||
@pytest.fixture | ||
def all_images(): | ||
"""Lists all images for testing""" | ||
return list_images("static") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This file contains all the development requirements for our linting toolchain. | ||
# Don't forget to pin your dependencies! | ||
# This list will have to be migrated if you wish to use another dependency manager. | ||
|
||
# Base tools | ||
flake8~=4.0.1 | ||
isort~=5.10.1 | ||
pre-commit~=2.17.0 | ||
|
||
# Flake8 plugins, see https://github.com/python-discord/code-jam-template/tree/main#plugin-list | ||
flake8-docstrings~=1.6.0 | ||
|
||
# Core tools | ||
nicegui~=1.3.13 | ||
Pillow~=10.0.0 | ||
numpy~=1.25.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from enum import Enum | ||
|
||
SOFTWARE_TITLE = "In Plain Pixel" | ||
TEAM_MEMBERS = "Davr, Jaavv, maxence, standard_affect" | ||
DESCRIPTION = "Python Discord Summer Code Jam 2023 - The Thick Wrappers Project" | ||
EXIF_MAKE = "IPP" | ||
STARTING_X = 0 | ||
STARTING_Y = 0 | ||
BITS_4 = 4 | ||
# R, G, B | ||
N_PLANES = 3 | ||
|
||
|
||
class ResizeMode(Enum): | ||
"""Enumeration for flag to shrink or leave image as is""" | ||
|
||
DEFAULT = 0 | ||
SHRINK_TO_SCALE = 1 | ||
|
||
|
||
class Sizing(Enum): | ||
"""Enumeration for flags on difference in secret image and cover image""" | ||
|
||
SMALLER = 0 | ||
BIGGER = 1 | ||
TALLER = 2 | ||
WIDER = 3 | ||
|
||
|
||
class Direction(Enum): | ||
"""Enumeration for direction of bit shift""" | ||
|
||
LEFT = 0 | ||
RIGHT = 1 | ||
UP = 2 | ||
DOWN = 3 | ||
|
||
|
||
class ExifData(Enum): | ||
"""Enumeration for metadata locations""" | ||
|
||
MAKE = 271 | ||
MODEL = 272 | ||
ARTIST = 315 | ||
SOFTWARE = 305 | ||
DESCRIPTION = 270 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from PIL.Image import Image | ||
|
||
from .constant import BITS_4, N_PLANES | ||
from .utility import parse_exif, pixels_to_binary | ||
|
||
|
||
def decrypt_text_from_image(img: Image) -> tuple[str, bool]: | ||
""" | ||
Decrypts an image encoded with text. | ||
|
||
param img: A Pillow Image object containing message | ||
This function iterates over an image's pixels and extracts the three least | ||
significant bits of each color plane. These values are summed and converted | ||
to the corresponding ASCII character. The function scans until it finds | ||
the message delimiter ",,,.." or it processes all pixels. It returns | ||
a tuple of the decrypted message and a bool indicating whether the | ||
delimiter (present in all valid messages) was found. | ||
""" | ||
delimiter = False | ||
pixel_list, word_total = [], "" | ||
RGB_binary_list = pixels_to_binary(img) | ||
|
||
# Iterates through each pixel's binary values and concatenates the least significant bits into decoded code | ||
for pixel in RGB_binary_list: | ||
output = "0" | ||
r, g, b = pixel[0][-N_PLANES:], pixel[1][-N_PLANES:], pixel[2][-1] | ||
output += f"{b}{g}{r}" | ||
pixel_list.append(int(output, 2)) | ||
|
||
# Iterates through each binary output and converts each binary to ASCII, simultaneously checking for the delimiter | ||
for binary in pixel_list: | ||
if word_total[-5:] == ",,,..": | ||
delimiter = True | ||
break | ||
word_total += format(binary, "c") | ||
return word_total[:-5], delimiter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise, |
||
|
||
|
||
def decrypt_image_from_image(image: Image) -> Image: | ||
""" | ||
Decrypts the secret image from the given input image. | ||
|
||
This function attempts to read the size data embedded in | ||
a cover image's metadata. Failing that, it decrypts the whole image. | ||
It should recover the four most significant bits of each pixel of the | ||
original image. | ||
|
||
:param image: Pillow image containing encrypted image. | ||
:return: The reconstruction of the original image. | ||
""" | ||
if size := parse_exif(image.getexif()): | ||
width, height = size | ||
image = image.crop((0, 0, width, height)) | ||
else: | ||
print("WARNING: Could not parse size from EXIF metadata. Falling back to decrypting whole image") | ||
|
||
return image.point(lambda byte: (byte & 0b00001111) << BITS_4) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect
',,,..'
to be defined once as a constant, so that you can change the delimiter in one place without having to make any other changes elsewhere in the code base.You could also have used the
str.endswith
method.