Skip to content
Snippets Groups Projects
Commit abbd1b74 authored by Donald Stufft's avatar Donald Stufft
Browse files

Don't decode the bytes from sha256/sha512

parent 64d75740
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ def sha256(message, binary=False):
if binary:
return digest
return binascii.hexlify(digest).decode("ascii")
return binascii.hexlify(digest)
def sha512(message, binary=False):
......@@ -23,4 +23,4 @@ def sha512(message, binary=False):
if binary:
return digest
return binascii.hexlify(digest).decode("ascii")
return binascii.hexlify(digest)
......@@ -5,11 +5,11 @@ import pytest
@pytest.mark.parametrize(("inp", "expected"), [
(
b"The quick brown fox jumps over the lazy dog.",
"ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c",
b"ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c",
),
(
b"",
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
b"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
)
])
def test_sha256_hex(inp, expected):
......@@ -33,11 +33,11 @@ def test_sha256_binary(inp, expected):
@pytest.mark.parametrize(("inp", "expected"), [
(
b"The quick brown fox jumps over the lazy dog.",
"91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed",
b"91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed",
),
(
b"",
"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
b"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
)
])
def test_sha512_hex(inp, expected):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment