Skip to content
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

Sh #3152

Closed
wants to merge 2 commits into from
Closed

Sh #3152

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions StenographyEncoding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Function to encode a message into an image
def encode_image(input_image_path, output_image_path, message):

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.8

Ruff (ANN201)

StenographyEncoding.py:2:5: ANN201 Missing return type annotation for public function `encode_image`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.8

Ruff (ANN001)

StenographyEncoding.py:2:18: ANN001 Missing type annotation for function argument `input_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.8

Ruff (ANN001)

StenographyEncoding.py:2:36: ANN001 Missing type annotation for function argument `output_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.8

Ruff (ANN001)

StenographyEncoding.py:2:55: ANN001 Missing type annotation for function argument `message`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.9

Ruff (ANN201)

StenographyEncoding.py:2:5: ANN201 Missing return type annotation for public function `encode_image`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.9

Ruff (ANN001)

StenographyEncoding.py:2:18: ANN001 Missing type annotation for function argument `input_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.9

Ruff (ANN001)

StenographyEncoding.py:2:36: ANN001 Missing type annotation for function argument `output_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.9

Ruff (ANN001)

StenographyEncoding.py:2:55: ANN001 Missing type annotation for function argument `message`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.10

Ruff (ANN201)

StenographyEncoding.py:2:5: ANN201 Missing return type annotation for public function `encode_image`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.10

Ruff (ANN001)

StenographyEncoding.py:2:18: ANN001 Missing type annotation for function argument `input_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.10

Ruff (ANN001)

StenographyEncoding.py:2:36: ANN001 Missing type annotation for function argument `output_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.10

Ruff (ANN001)

StenographyEncoding.py:2:55: ANN001 Missing type annotation for function argument `message`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.11

Ruff (ANN201)

StenographyEncoding.py:2:5: ANN201 Missing return type annotation for public function `encode_image`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.11

Ruff (ANN001)

StenographyEncoding.py:2:18: ANN001 Missing type annotation for function argument `input_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.11

Ruff (ANN001)

StenographyEncoding.py:2:36: ANN001 Missing type annotation for function argument `output_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.11

Ruff (ANN001)

StenographyEncoding.py:2:55: ANN001 Missing type annotation for function argument `message`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.12

Ruff (ANN201)

StenographyEncoding.py:2:5: ANN201 Missing return type annotation for public function `encode_image`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.12

Ruff (ANN001)

StenographyEncoding.py:2:18: ANN001 Missing type annotation for function argument `input_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.12

Ruff (ANN001)

StenographyEncoding.py:2:36: ANN001 Missing type annotation for function argument `output_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.12

Ruff (ANN001)

StenographyEncoding.py:2:55: ANN001 Missing type annotation for function argument `message`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.10 no-toml

Ruff (ANN201)

StenographyEncoding.py:2:5: ANN201 Missing return type annotation for public function `encode_image`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.10 no-toml

Ruff (ANN001)

StenographyEncoding.py:2:18: ANN001 Missing type annotation for function argument `input_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.10 no-toml

Ruff (ANN001)

StenographyEncoding.py:2:36: ANN001 Missing type annotation for function argument `output_image_path`

Check failure on line 2 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.10 no-toml

Ruff (ANN001)

StenographyEncoding.py:2:55: ANN001 Missing type annotation for function argument `message`
img = Image.open(input_image_path)

Check failure on line 3 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.8

Ruff (F821)

StenographyEncoding.py:3:11: F821 Undefined name `Image`

Check failure on line 3 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.9

Ruff (F821)

StenographyEncoding.py:3:11: F821 Undefined name `Image`

Check failure on line 3 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.10

Ruff (F821)

StenographyEncoding.py:3:11: F821 Undefined name `Image`

Check failure on line 3 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.11

Ruff (F821)

StenographyEncoding.py:3:11: F821 Undefined name `Image`

Check failure on line 3 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.12

Ruff (F821)

StenographyEncoding.py:3:11: F821 Undefined name `Image`

Check failure on line 3 in StenographyEncoding.py

View workflow job for this annotation

GitHub Actions / 3.10 no-toml

Ruff (F821)

StenographyEncoding.py:3:11: F821 Undefined name `Image`
width, height = img.size
pixel_index = 0
binary_message = "".join(format(ord(char), "08b") for char in message)

if len(binary_message) > width * height:
print("Message is too large for this image.")
return

for x in range(width):
for y in range(height):
pixel = list(img.getpixel((x, y)))
for color_channel in range(3): # RGB channels
if pixel_index < len(binary_message):
pixel[color_channel] = int(
bin(pixel[color_channel])[2:-1] + binary_message[pixel_index], 2
)
pixel_index += 1
else:
break
img.putpixel((x, y), tuple(pixel))

img.save(output_image_path)


# Example usage
message_to_hide = "This example of Stenography."
input_image = "madmax.jpg"
output_image = "output_image.png"

# Encode the message into the image
encode_image(input_image, output_image, message_to_hide)
print("Encoded Message: ", message_to_hide)
Loading