Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Floris Valentijn
Covert-Channel-ANS-Group-11
Commits
9fe5b8fd
Commit
9fe5b8fd
authored
Dec 08, 2021
by
Floris Valentijn
Browse files
Upload New File
parent
ab0df80f
Changes
1
Hide whitespace changes
Inline
Side-by-side
message_encoder.py
0 → 100644
View file @
9fe5b8fd
from
PIL
import
Image
import
numpy
as
np
secret
=
"Hello, World"
bin_secret_list
=
[]
# convert secret string to byte string
for
letter
in
secret
:
ASCII
=
ord
(
letter
)
bin_secret_list
.
append
(
format
(
ASCII
,
'08b'
))
bin_secret
=
''
.
join
(
bin_secret_list
)
bin_secret
+=
"00000000"
image
=
Image
.
open
(
'beemovie.png'
)
img
=
np
.
array
(
image
)
# encode secret byte string in the red color of the image
i
=
0
for
row
in
img
:
for
col
in
row
:
if
i
<
len
(
bin_secret
):
R
=
col
[
0
]
col
[
0
]
=
int
(
format
(
R
,
'08b'
)[:
-
1
]
+
bin_secret
[
i
],
2
)
i
+=
1
save_image
=
Image
.
fromarray
(
img
)
save_image
.
save
(
'encoded_beemovie.png'
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment