refactored BIP38 helper functions