Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Steganorgraphy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PRASHANT SAROJ
Steganorgraphy
Commits
d0071637
Commit
d0071637
authored
Sep 22, 2018
by
Prashant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding decode.py. This file is used for retrieving hidden message
parent
a416c531
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
decode.py
decode.py
+64
-0
No files found.
decode.py
0 → 100644
View file @
d0071637
from
PIL
import
Image
def
decodeLzw
(
compressed
):
dict_size
=
256
dictionary
=
{}
for
i
in
range
(
dict_size
):
dictionary
[
i
]
=
chr
(
i
)
if
compressed
:
w
=
chr
(
compressed
.
pop
(
0
))
result
=
[
w
]
for
k
in
compressed
:
if
k
in
dictionary
:
entry
=
dictionary
[
k
]
elif
k
==
len
(
dictionary
):
entry
=
w
+
w
[
0
]
result
.
append
(
entry
)
dictionary
[
dict_size
]
=
w
+
entry
[
0
]
dict_size
+=
1
w
=
entry
return
''
.
join
(
result
)
if
__name__
==
'__main__'
:
img
=
Image
.
open
(
'output.png'
)
pixelMap
=
img
.
load
()
# extracting the length of compressed message
compressed_len
=
1
# there is extra character in encoded_version
for
i
in
range
(
0
,
8
):
compressed_len
=
compressed_len
+
(
pixelMap
[
0
,
i
][
0
]
%
4
)
*
(
4
**
(
7
-
i
))
compressed
=
[]
curr_code
=
0
code_ctr
=
0
loop_ctr
=
0
for
i
in
range
(
0
,
img
.
size
[
0
]):
for
j
in
range
(
0
,
img
.
size
[
1
]):
if
loop_ctr
>
compressed_len
*
8
:
break
;
if
code_ctr
==
8
:
compressed
.
append
(
curr_code
)
curr_code
=
(
pixelMap
[
i
,
j
][
0
]
%
4
)
*
(
4
**
7
)
code_ctr
=
1
else
:
curr_code
=
curr_code
+
(
pixelMap
[
i
,
j
][
0
]
%
4
)
*
(
4
**
(
7
-
code_ctr
))
code_ctr
=
code_ctr
+
1
loop_ctr
=
loop_ctr
+
1
if
loop_ctr
>
compressed_len
*
8
:
break
;
n
=
len
(
compressed
)
-
1
compressed
[
0
],
compressed
[
n
]
=
compressed
[
n
],
compressed
[
0
]
compressed
.
pop
(
n
)
print
(
decodeLzw
(
compressed
))
\ No newline at end of file
Write
Preview
Markdown
is supported
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