Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
binwalk
Commits
5b6c4cee
Commit
5b6c4cee
authored
Oct 27, 2020
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Regressed entropy updates due to TypeError's
parent
83f19dfc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
entropy.py
src/binwalk/modules/entropy.py
+9
-9
No files found.
src/binwalk/modules/entropy.py
View file @
5b6c4cee
...
...
@@ -8,10 +8,10 @@ import binwalk.core.common
from
binwalk.core.compat
import
*
from
binwalk.core.module
import
Module
,
Option
,
Kwarg
try
:
import
numpy
as
np
except
ImportError
:
pass
#
try:
#
import numpy as np
#
except ImportError:
#
pass
try
:
from
numba
import
njit
except
ImportError
:
...
...
@@ -238,14 +238,14 @@ class Entropy(Module):
entropy
=
0
if
data
:
data
=
data
.
encode
(
'latin-1'
)
length
=
len
(
data
)
seen
=
[
0
]
*
256
seen
=
dict
(((
chr
(
x
),
0
)
for
x
in
range
(
0
,
256
)))
for
byte
in
data
:
seen
[
byte
]
+=
1
for
x
in
seen
:
p_x
=
float
(
x
)
/
length
for
x
in
range
(
0
,
256
)
:
p_x
=
float
(
seen
[
chr
(
x
)]
)
/
length
if
p_x
>
0
:
entropy
-=
p_x
*
math
.
log
(
p_x
,
2
)
...
...
@@ -253,7 +253,7 @@ class Entropy(Module):
def
shannon_numpy
(
self
,
data
):
if
data
:
return
self
.
_shannon_numpy
(
data
.
encode
(
'latin-1'
))
return
self
.
_shannon_numpy
(
bytes2str
(
data
))
else
:
return
0
...
...
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