prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  crypto_recognizer throws an exception
  
  When calling the engine analyze API  like
  
  ```
   response = engine.analyze(correlation_id=0,
                                        text=text_to_analyze,
                                        language='en',
                                        entities=[],
                                        all_fields=True,
                                        score_threshold=0.5)
  ```
  
  and the value of  'text_to_analyze' is 
  
  "/boardingPass/v1/devices/34e7b5e1a0aa1d6f3d862b52a289cdb7/registrations/pass.apoc.wallet/"
  
  The exception below is thrown
  
  
  ` File "/home/folder_name/presidio_testing/my_venv/lib/python3.6/site-packages/analyzer/analyzer_engine.py", line 204, in analyze
      current_results = recognizer.analyze(text, entities, nlp_artifacts)
    File "/home/folder_name/presidio_testing/my_venv/lib/python3.6/site-packages/analyzer/pattern_recognizer.py", line 61, in analyze
      pattern_result = self.__analyze_patterns(text)
    File "/home/folder_name/presidio_testing/my_venv/lib/python3.6/site-packages/analyzer/pattern_recognizer.py", line 144, in __analyze_patterns
      validation_result = self.validate_result(current_match)
    File "/home/folder_name/presidio_testing/my_venv/lib/python3.6/site-packages/analyzer/predefined_recognizers/crypto_recognizer.py", line 23, in validate_result
      bcbytes = CryptoRecognizer.__decode_base58(pattern_text, 25)
    File "/home/folder_name/presidio_testing/my_venv/lib/python3.6/site-packages/analyzer/predefined_recognizers/crypto_recognizer.py", line 33, in __decode_base58
      n = n * 58 + digits58.index(char)`
  
  ValueError: substring not found
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py`
  Content:
  ```
  1 from hashlib import sha256
  2 from analyzer import Pattern
  3 from analyzer import PatternRecognizer
  4 
  5 # Copied from:
  6 # http://rosettacode.org/wiki/Bitcoin/address_validation#Python
  7 REGEX = r'\b[13][a-km-zA-HJ-NP-Z0-9]{26,33}\b'
  8 CONTEXT = ["wallet", "btc", "bitcoin", "crypto"]
  9 
  10 
  11 class CryptoRecognizer(PatternRecognizer):
  12     """
  13     Recognizes common crypto account numbers using regex + checksum
  14     """
  15 
  16     def __init__(self):
  17         patterns = [Pattern('Crypto (Medium)', REGEX, 0.5)]
  18         super().__init__(supported_entity="CRYPTO", patterns=patterns,
  19                          context=CONTEXT)
  20 
  21     def validate_result(self, pattern_text):
  22         # try:
  23         bcbytes = CryptoRecognizer.__decode_base58(pattern_text, 25)
  24         result = bcbytes[-4:] == sha256(sha256(bcbytes[:-4])
  25                                         .digest()).digest()[:4]
  26         return result
  27 
  28     @staticmethod
  29     def __decode_base58(bc, length):
  30         digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
  31         n = 0
  32         for char in bc:
  33             n = n * 58 + digits58.index(char)
  34         return n.to_bytes(length, 'big')
  35
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py b/presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py
  --- a/presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py
  +++ b/presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py
  @@ -4,7 +4,7 @@
   
   # Copied from:
   # http://rosettacode.org/wiki/Bitcoin/address_validation#Python
  -REGEX = r'\b[13][a-km-zA-HJ-NP-Z0-9]{26,33}\b'
  +REGEX = r'\b[13][a-km-zA-HJ-NP-Z1-9]{26,33}\b'
   CONTEXT = ["wallet", "btc", "bitcoin", "crypto"]
   
   
  @@ -19,11 +19,12 @@
                            context=CONTEXT)
   
       def validate_result(self, pattern_text):
  -        # try:
  -        bcbytes = CryptoRecognizer.__decode_base58(pattern_text, 25)
  -        result = bcbytes[-4:] == sha256(sha256(bcbytes[:-4])
  -                                        .digest()).digest()[:4]
  -        return result
  +        try:
  +            bcbytes = CryptoRecognizer.__decode_base58(pattern_text, 25)
  +            return bcbytes[-4:] == sha256(sha256(bcbytes[:-4])
  +                                          .digest()).digest()[:4]
  +        except ValueError:
  +            return False
   
       @staticmethod
       def __decode_base58(bc, length):
  
verification_info: {"golden_diff": "diff --git a/presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py b/presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py\n--- a/presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py\n+++ b/presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py\n@@ -4,7 +4,7 @@\n \n # Copied from:\n # http://rosettacode.org/wiki/Bitcoin/address_validation#Python\n-REGEX = r'\\b[13][a-km-zA-HJ-NP-Z0-9]{26,33}\\b'\n+REGEX = r'\\b[13][a-km-zA-HJ-NP-Z1-9]{26,33}\\b'\n CONTEXT = [\"wallet\", \"btc\", \"bitcoin\", \"crypto\"]\n \n \n@@ -19,11 +19,12 @@\n                          context=CONTEXT)\n \n     def validate_result(self, pattern_text):\n-        # try:\n-        bcbytes = CryptoRecognizer.__decode_base58(pattern_text, 25)\n-        result = bcbytes[-4:] == sha256(sha256(bcbytes[:-4])\n-                                        .digest()).digest()[:4]\n-        return result\n+        try:\n+            bcbytes = CryptoRecognizer.__decode_base58(pattern_text, 25)\n+            return bcbytes[-4:] == sha256(sha256(bcbytes[:-4])\n+                                          .digest()).digest()[:4]\n+        except ValueError:\n+            return False\n \n     @staticmethod\n     def __decode_base58(bc, length):\n", "issue": "crypto_recognizer throws an exception\n\r\nWhen calling the engine analyze API  like\r\n\r\n```\r\n response = engine.analyze(correlation_id=0,\r\n                                      text=text_to_analyze,\r\n                                      language='en',\r\n                                      entities=[],\r\n                                      all_fields=True,\r\n                                      score_threshold=0.5)\r\n```\r\n\r\nand the value of  'text_to_analyze' is \r\n\r\n\"/boardingPass/v1/devices/34e7b5e1a0aa1d6f3d862b52a289cdb7/registrations/pass.apoc.wallet/\"\r\n\r\nThe exception below is thrown\r\n\r\n\r\n` File \"/home/folder_name/presidio_testing/my_venv/lib/python3.6/site-packages/analyzer/analyzer_engine.py\", line 204, in analyze\r\n    current_results = recognizer.analyze(text, entities, nlp_artifacts)\r\n  File \"/home/folder_name/presidio_testing/my_venv/lib/python3.6/site-packages/analyzer/pattern_recognizer.py\", line 61, in analyze\r\n    pattern_result = self.__analyze_patterns(text)\r\n  File \"/home/folder_name/presidio_testing/my_venv/lib/python3.6/site-packages/analyzer/pattern_recognizer.py\", line 144, in __analyze_patterns\r\n    validation_result = self.validate_result(current_match)\r\n  File \"/home/folder_name/presidio_testing/my_venv/lib/python3.6/site-packages/analyzer/predefined_recognizers/crypto_recognizer.py\", line 23, in validate_result\r\n    bcbytes = CryptoRecognizer.__decode_base58(pattern_text, 25)\r\n  File \"/home/folder_name/presidio_testing/my_venv/lib/python3.6/site-packages/analyzer/predefined_recognizers/crypto_recognizer.py\", line 33, in __decode_base58\r\n    n = n * 58 + digits58.index(char)`\r\n\r\nValueError: substring not found\n", "before_files": [{"content": "from hashlib import sha256\nfrom analyzer import Pattern\nfrom analyzer import PatternRecognizer\n\n# Copied from:\n# http://rosettacode.org/wiki/Bitcoin/address_validation#Python\nREGEX = r'\\b[13][a-km-zA-HJ-NP-Z0-9]{26,33}\\b'\nCONTEXT = [\"wallet\", \"btc\", \"bitcoin\", \"crypto\"]\n\n\nclass CryptoRecognizer(PatternRecognizer):\n    \"\"\"\n    Recognizes common crypto account numbers using regex + checksum\n    \"\"\"\n\n    def __init__(self):\n        patterns = [Pattern('Crypto (Medium)', REGEX, 0.5)]\n        super().__init__(supported_entity=\"CRYPTO\", patterns=patterns,\n                         context=CONTEXT)\n\n    def validate_result(self, pattern_text):\n        # try:\n        bcbytes = CryptoRecognizer.__decode_base58(pattern_text, 25)\n        result = bcbytes[-4:] == sha256(sha256(bcbytes[:-4])\n                                        .digest()).digest()[:4]\n        return result\n\n    @staticmethod\n    def __decode_base58(bc, length):\n        digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n        n = 0\n        for char in bc:\n            n = n * 58 + digits58.index(char)\n        return n.to_bytes(length, 'big')\n", "path": "presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py"}], "after_files": [{"content": "from hashlib import sha256\nfrom analyzer import Pattern\nfrom analyzer import PatternRecognizer\n\n# Copied from:\n# http://rosettacode.org/wiki/Bitcoin/address_validation#Python\nREGEX = r'\\b[13][a-km-zA-HJ-NP-Z1-9]{26,33}\\b'\nCONTEXT = [\"wallet\", \"btc\", \"bitcoin\", \"crypto\"]\n\n\nclass CryptoRecognizer(PatternRecognizer):\n    \"\"\"\n    Recognizes common crypto account numbers using regex + checksum\n    \"\"\"\n\n    def __init__(self):\n        patterns = [Pattern('Crypto (Medium)', REGEX, 0.5)]\n        super().__init__(supported_entity=\"CRYPTO\", patterns=patterns,\n                         context=CONTEXT)\n\n    def validate_result(self, pattern_text):\n        try:\n            bcbytes = CryptoRecognizer.__decode_base58(pattern_text, 25)\n            return bcbytes[-4:] == sha256(sha256(bcbytes[:-4])\n                                          .digest()).digest()[:4]\n        except ValueError:\n            return False\n\n    @staticmethod\n    def __decode_base58(bc, length):\n        digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n        n = 0\n        for char in bc:\n            n = n * 58 + digits58.index(char)\n        return n.to_bytes(length, 'big')\n", "path": "presidio-analyzer/analyzer/predefined_recognizers/crypto_recognizer.py"}]}