Skip to main content

Miscellaneous functions written in short forms.

Project description

Omnitools

version license pyversions
donate powered made

Miscellaneous functions written in short forms.

Hierarchy

omnitools
|---- encoding
|   |---- b64
|   |   |---- b64d()
|   |   |---- b64e()
|   |   |---- try_b64d()
|   |   '---- b64d_or_utf8e()
|   |---- file
|   |   '---- charenc()
|   '---- utf8
|       |---- utf8d()
|       |---- utf8e()
|       |---- try_utf8d()
|       '---- try_utf8e()
|---- hashing
|   |---- mac()
|   '---- sha512()
|---- rng
|   |---- randb()
|   '---- randi()
|---- stdout
|   '---- p()
'---- type
    |---- str_or_bytes
    |---- list_or_dict
    |---- key_pair_format
    |---- encryptedsocket_function
    '---- Obj()

Example

python

from omnitools import *

# print and always flush buffer
p("abc")
# abc
# 

# base64 decode
p(b64d(b64e("test")))
# test

# base64 encode
p(b64e("test"))
# dGVzdA==

# try b64d str except return itself
p(try_b64d("test"))
# test

# try b64d str except utf8e str
p(b64d_or_utf8e(randb(64)))
# b"..."

# detect character encoding
p(charenc(b"\xe3\x81\x82"))
# utf-8

# utf8 decode
p(utf8d(utf8e("test")))
# test

# utf8 encode
p(utf8e("test"))
# b"test"

# try utf8d bytes except return itself
p(try_utf8d("test"))

# try utf8e str except return itself
p(try_utf8e(randb(64)))

# hash mac with hmac, sha3_512
p(mac(content="test", key=randb(64)))
# ...

# hash with sha3_512
p(sha512("test"))
# ...

# generate random 64 bytes
p(randb(64))
# b"..."

# generate int from 10**power to 10**(power+1)-1
p(randi(power=2))
# 101 # from 100 to 999

# turn (nested) dict into an object
p(Obj({"a":{"b":{"c":123}}}).a.b.c)
# 123

shell

rem omnitools.exe <function name> [argument] ...
omnitools.exe p abc

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

omnitools-0.0.56.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

omnitools-0.0.56-py3-none-any.whl (18.8 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