Skip to main content

Convert between bases, initailly intended for RFC4648 base32

Project description

Universal base converter

Use either with predefined converters:

  • integer to base32(RFC4648)
  • integer to hex
  • base32(RFC4648) to integer

Or use with custom settings:

  • set base
  • set charset

Examples:

if __name__ == "__main__":
    # example:
    num = 15851

    # using instance of converter, using custom settings
    converter = Convertbase()
    converter.set_base(32)
    converter.set_charset('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567')

    print(converter.convert(num))

    # or using static methods:
    print(Convertbase.to_b32(num))

    # hex, compare to built-in
    print(Convertbase.to_hex(num))
    print(hex(num))

    #convert back:
    print(Convertbase.from_b32_to_dec('PPL'))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

convertbase-0.1.3.tar.gz (2.3 kB view hashes)

Uploaded Source

Built Distribution

convertbase-0.1.3-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page