code: def b58encode(v: bytes) -> str:
      '''Encode a string using Base58'''
  
      origlen = len(v)
      v = v.lstrip(b'\0')
      newlen = len(v)
  
      p, acc = 1, 0
      for c in iseq(v[::-1]):
          acc += p * c
          p = p << 8
  
      result = ''
      while acc > 0:
          acc, mod = divmod(acc, 58)
          result += alphabet[mod]
  
      return (result + alphabet[0] * (origlen - newlen))[::-1f b58encode(v: bytes) -> str:
      '''Encode a string using Base58'''
  
      origlen = len(v)
      v = v.lstrip(b'\0')
      newlen = len(v)
  
      p, acc = 1, 0
      for c in iseq(v[::-1]):
          acc += p * c
          p = p << 8
  
      result = ''
      while acc > 0:
          acc, mod = divmod(acc, 58)
          result += alphabet[mod]
  
      return (result + alphabet[0] * (origlen - newlen))[::-1]
docs: Encode a string using Base58