Repository: keis/base58

Issue:
b58encode_check does not take a str as input
b58encode_check only takes `bytes` as input. This is inconsistent with b58encode, which can handle a `Union[str, bytes]` as input.

Discussion:

Patch:
diff --git a/base58.py b/base58.py
index f1bded6..71c49c4 100644
--- a/base58.py
+++ b/base58.py
@@ -103,10 +103,13 @@ def b58decode(
     return b'\0' * (origlen - newlen) + bytes(reversed(result))
 
 
-def b58encode_check(v: bytes, alphabet: bytes = BITCOIN_ALPHABET) -> bytes:
+def b58encode_check(
+    v: Union[str, bytes], alphabet: bytes = BITCOIN_ALPHABET
+) -> bytes:
     """
     Encode a string using Base58 with a 4 character checksum
     """
+    v = scrub_input(v)
 
     digest = sha256(sha256(v).digest()).digest()
     return b58encode(v + digest[:4], alphabet=alphabet)


Test patch:
diff --git a/test_base58.py b/test_base58.py
index f007ee8..98d921b 100644
--- a/test_base58.py
+++ b/test_base58.py
@@ -76,6 +76,14 @@ def test_check_identity():
     assert_that(out, equal_to(data))
 
 
+def test_check_str():
+    data = 'hello world'
+    out = b58encode_check(data)
+    assert_that(out, equal_to(b'3vQB7B6MrGQZaxCuFg4oh'))
+    back = b58decode_check(out)
+    assert_that(back, b'hello world')
+
+
 def test_check_failure():
     data = '3vQB7B6MrGQZaxCuFg4oH'
     with assert_raises(ValueError):