Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
a731ddca
Commit
a731ddca
authored
12 years ago
by
Donald Stufft
Browse files
Options
Downloads
Patches
Plain Diff
Add tests to verify that hashing is accurately occuring
parent
21e1d0bf
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_hash.py
+58
-0
58 additions, 0 deletions
tests/test_hash.py
with
58 additions
and
0 deletions
tests/test_hash.py
0 → 100644
+
58
−
0
View file @
a731ddca
import
nacl
import
pytest
@pytest.mark.parametrize
((
"
inp
"
,
"
expected
"
),
[
(
b
"
The quick brown fox jumps over the lazy dog.
"
,
"
ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c
"
,
),
(
b
""
,
"
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
"
,
)
])
def
test_sha256_hex
(
inp
,
expected
):
assert
nacl
.
hash
.
sha256
(
inp
)
==
expected
@pytest.mark.parametrize
((
"
inp
"
,
"
expected
"
),
[
(
b
"
The quick brown fox jumps over the lazy dog.
"
,
b
"
\xEF
S
\x7F
%
\xC8\x95\xBF\xA7\x82
Re)
\xA9\xB6
=
\x97\xAA
c
\x15
d
\xD5\xD7\x89\xC2\xB7
eD
\x8C\x86
5
\xFB
l
"
,
),
(
b
""
,
b
"
\xe3\xb0\xc4
B
\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99
o
\xb9
$
'
\xae
A
\xe4
d
\x9b\x93
L
\xa4\x95\x99\x1b
xR
\xb8
U
"
,
)
])
def
test_sha256_binary
(
inp
,
expected
):
assert
nacl
.
hash
.
sha256
(
inp
,
binary
=
True
)
==
expected
@pytest.mark.parametrize
((
"
inp
"
,
"
expected
"
),
[
(
b
"
The quick brown fox jumps over the lazy dog.
"
,
"
91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed
"
,
),
(
b
""
,
"
cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
"
,
)
])
def
test_sha512_hex
(
inp
,
expected
):
assert
nacl
.
hash
.
sha512
(
inp
)
==
expected
@pytest.mark.parametrize
((
"
inp
"
,
"
expected
"
),
[
(
b
"
The quick brown fox jumps over the lazy dog.
"
,
b
"
\x91\xEA\x12
E
\xF2\r
F
\xAE\x9A\x03
z
\x98\x9F
T
\xF1\xF7\x90\xF0\xA4
v
\a\xEE\xB8\xA1
M
\x12\x89\f\xEA
w
\xA1\xBB\xC6\xC7\xED\x9C\xF2\x05\xE6
{
\x7F
+
\x8F\xD4\xC7\xDF\xD3\xA7\xA8
a~E
\xF3\xC4
c
\xD4\x81\xC7\xE5\x86\xC3\x9A\xC1\xED
"
,
),
(
b
""
,
b
"
\xCF\x83\xE1
5~
\xEF\xB8\xBD\xF1
T(P
\xD6
m
\x80\a\xD6
\xE4\x05\v
W
\x15\xDC\x83\xF4\xA9
!
\xD3
l
\xE9\xCE
G
\xD0\xD1
<]
\x85\xF2\xB0\xFF\x83\x18\xD2\x87
~
\xEC
/c
\xB9
1
\xBD
GAz
\x81\xA5
82z
\xF9
'
\xDA
>
"
,
)
])
def
test_sha512_binary
(
inp
,
expected
):
assert
nacl
.
hash
.
sha512
(
inp
,
binary
=
True
)
==
expected
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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