Skip to content

Commit 5210b90

Browse files
authored
Merge pull request #7 from brentru/add-argument-to-sha1
Update sha1 constructor
2 parents c0330a1 + 7a5359c commit 5210b90

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

adafruit_hashlib/_sha1.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ class sha1():
128128
digest_size = SHA_DIGESTSIZE
129129
block_size = SHA_BLOCKSIZE
130130
name = "sha1"
131-
def __init__(self):
131+
def __init__(self, data=None):
132132
"""Construct a SHA-1 hash object.
133-
:param bytes data: data to process
133+
:param bytes data: Optional data to process
134+
134135
"""
135136
# Initial Digest Variables
136137
self._h = (0x67452301,
@@ -146,6 +147,9 @@ def __init__(self):
146147
# Length in bytes of all data that has been processed so far
147148
self._msg_byte_len = 0
148149

150+
if data:
151+
self.update(data)
152+
149153
def _create_digest(self):
150154
"""Returns finalized digest variables for the data processed so far.
151155

0 commit comments

Comments
 (0)