Skip to content

Hashes don't match hashlib #1

@kellieotto

Description

@kellieotto

The following test fails. It's a variant on the test in test_sha256.py. Basically instead of creating a new message at each step, I append a byte to the previous message at each step.

from sha256 import sha256 as c_sha256, sha256rand
from hashlib import sha256

print('Verifying integrity of hashes between Python and C SHA256:')

const_byte = bytes(1)
message = b"counter"
for i in range(1000):
    message = message+const_byte
    result0 = c_sha256(message)

    s = sha256()
    s.update(message)
    result1 = s.digest()

    assert result0 == result1
    print('.', end='')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions