Skip to content

Commit

Permalink
Fix sha256
Browse files Browse the repository at this point in the history
  • Loading branch information
reverse.hash committed May 7, 2023
1 parent 4105195 commit bb6142e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions understandingbitcoin/hash/sha256.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Sha256:

"""
SHA-256 is a cryptographic hash function that generates a 256-bit
(32-byte) hash value and is used for digital signatures, data integrity
Expand Down Expand Up @@ -88,10 +87,10 @@ def _extend_message(cls, message: bytes) -> ByteBuffer:
# and k bytes 0x00 so that the length in bits of the padded message
# becomes congruent to 448, modulo 512
extended_message.put_byte(0x80)
k = cls._BLOCK_SIZE_BYTES - ((len(message)
+ 1 # byte added in the previous line
+ cls._MESSAGE_LENGTH_SIZE_BYTES)
% cls._BLOCK_SIZE_BYTES)
k: int = cls._BLOCK_SIZE_BYTES - ((len(message)
+ 1 # byte added previously
+ cls._MESSAGE_LENGTH_SIZE_BYTES)
% cls._BLOCK_SIZE_BYTES)
for _ in range(k):
extended_message.put_byte(0x00)

Expand Down

0 comments on commit bb6142e

Please sign in to comment.