Errors handling crypt.crypt returning byte array instead of string
*Created originally on Bitbucket by Anonymous*
The `safe_crypt()` method defined in `utils/__init__.py` \([https://bitbucket.org/ecollins/passlib/src/f16891c4a7cb50cca16ccbce29a342bd0f0d2ad5/passlib/utils/\_\_init\_\_.py#lines-791](https://bitbucket.org/ecollins/passlib/src/f16891c4a7cb50cca16ccbce29a342bd0f0d2ad5/passlib/utils/__init__.py#lines-791)\) expects the result of `crypt()` to be a string, however I’ve found that on some systems \(and more recent Python3/PyPy3 versions\) it will be a byte array.
Thus the check for invalid prefixes fails as `result[0]` will receive an `int` not a `str`.
Placing the following two lines before the check fixes the issue:
```python
if isinstance(result, bytes):
result = result.decode('utf-8')
```
I haven’t been able to find out exactly _why_ this output has changed, but I found that `crypt.crypt` returns byte arrays in all Py3 versions on my server \(running Debian 10.2\)
issue