Skip to content

smemsh/utilpy

Repository files navigation

utilpy

Collection of shell utilities, written in Python.

(once they become large or more useful, they will probably get moved to their own repositories)



output random password from [[:alnum:]] ^ [0Ol1I], default 128 bits

  • generates a random password with specifiable entropy
  • chars: a-z, A-Z, 0-9, except: 0, O, l, 1, I (== 57 possible)
  • default 22 char password (~128 bits entropy using our charset)
  • uses python random.SystemRandom (on linux, os.urandom())
  • uses random.choice() to map into range of suitable characters

args:

  • arg1: number of bits of entropy the secret should have, default 128

calculation:

passlen = 22
setsize = len([[:alnum:]]) - 5 # ([^0Ol1I])
        = 26 + 26 + 10 - 5 = 57
entropy = log2(setsize^passlen)
        = log2(setsize) * passlen
        = passlen * (ln(setsize) / ln(2))
        = 22 * (ln(57) / ln(2))
        = 128.3235803212

todo:

  • allow to specify length instead of computing by entropy
  • allow to specify character set

also:

https://en.wikipedia.org/wiki/Password_strength

Pretty prints yaml files as python objects.

args: any number of yaml files to print
todo: optionally pre-pass through jinja2

Counts lines in the standard input, or the given files.

  • equivalent to wc -l (different output format if files given)
  • 5x slower than C version (wc -l) in measurements, python-3.9.5

Prints sys.path on separate lines, using interpreter as given in invocation (python, python2 or python3 for pypath, py2path, and py3path, respectively).

example:

$ py3path
/home/scott/bin
/opt/python-3.12.6/lib/python312.zip
/opt/python-3.12.6/lib/python3.12
/opt/python-3.12.6/lib/python3.12/lib-dynload
/home/scott/.local/lib/python3.12/site-packages
/opt/python-3.12.6/lib/python3.12/site-packages

About

bin: assorted shell utilities, in python

Resources

Stars

Watchers

Forks

Packages

No packages published