python-utilitybelt
python-utilitybelt copied to clipboard
charset_to_int drops characters on some inputs
To reproduce:
>>> from utilitybelt import charset_to_int
>>> from utilitybelt import base32_chars
>>> charset_to_int("AARDVARK", base32_chars)
574259754
>>> charset_to_int("RDVARK", base32_chars)
574259754
When the leading characters of s are the first element of the charset, they are not included in the returned integer. This is because output starts as 0 and is then multiplied by some number added to an index, which in these cases is also 0.
This behavior becomes an issue in the secret sharing library (https://github.com/blockstack/secret-sharing/) that depends on utilitybelt, as it corrupts secrets and leaks information about secret contents.
One possible fix is to initialize output as 1 instead of 0.