Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gr-tpms
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cyber-teachers
gr-tpms
Commits
eb6697ba
Commit
eb6697ba
authored
6 years ago
by
Joseph M Ernst
Browse files
Options
Downloads
Patches
Plain Diff
added checksum_calculator
parent
862a3eaa
Branches
master
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/checksum_calculator.py
+30
-0
30 additions, 0 deletions
apps/checksum_calculator.py
with
30 additions
and
0 deletions
apps/checksum_calculator.py
0 → 100644
+
30
−
0
View file @
eb6697ba
import
sys
def
usage
():
print
"
python checksum_calculator.py DATA
"
print
"
Examples:
"
print
"
python checksum_calculator.py 00000000004C900070B5948D0042
"
print
"""
python checksum_calculator.py
"
00 00 00 00 00 4C 90 00 70 B5 94 8D 00 42 64
"
"""
if
__name__
==
'
__main__
'
:
print
len
(
sys
.
argv
)
if
len
(
sys
.
argv
)
!=
2
:
usage
()
sys
.
exit
(
-
1
)
data_in
=
sys
.
argv
[
1
]
data
=
data_in
.
replace
(
"
"
,
""
)
print
data
if
len
(
data
)
!=
32
:
raise
Exception
(
"
length of data should be 28. Current length is %d
"
%
len
(
data
))
checksum
=
0
for
i
in
range
(
len
(
data
)
/
2
):
byte
=
int
(
'
0x
'
+
data
[
i
*
2
:
i
*
2
+
2
],
16
)
checksum
+=
byte
print
"
checksum: %02X
"
%
(
checksum
&
0xFF
)
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment