PKSL] random_cli.py#!/usr/bin/env python3 """ a cli app that simply generates a random 64 character alphanumeric string. """ __version__ = "0.1.2" import secrets import string import click @click.command() @click.option( '--type', default='alphanumeric', help='type of characters to be generated.') @click.argument('length', required=False, default=64) def random_cli(type, length): if 'alphanumeric' == type: click.echo(random_alphanumeric_string(length)) elif 'hex' == type: click.echo(random_hex_string(length)) elif type in ['print', 'printable']: click.echo(random_printable_string(length)) elif type in ['lower', 'lowercase']: click.echo(random_string(length, string.ascii_lowercase)) elif type in ['upper', 'uppercase']: click.echo(random_string(length, string.ascii_uppercase)) elif type in ['letter', 'letters', 'alpha']: click.echo(random_string(length, string.ascii_letters)) def random_alphanumeric_string(len): alphanumeric = string.ascii_letters + string.digits return random_string(len, alphanumeric) def random_hex_string(len): return random_string(len, string.hexdigits) def random_printable_string(len): printable = string.ascii_letters + string.digits + string.punctuation return random_string(len, printable) def random_string(len, characters): result = '' while len > 0: result += secrets.choice(characters) len -= 1 return result if __name__ == '__main__': random_cli() PK!Hf%0+random_cli-0.1.2.dist-info/entry_points.txtN+I/N.,()*JKϵP9V&PK'J%random_cli-0.1.2.dist-info/LICENSE.mdCopyright (c) 2017, sunnz (https://github.com/sunnz) Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. PK!HxQP random_cli-0.1.2.dist-info/WHEEL1 0 RZq+D-Dv;_[*7Fp 8MRq%_:==ߘPT PK!H1XNr #random_cli-0.1.2.dist-info/METADATAVMo#E7Er b7q=3eO?5Bv^u'N6pJ"OWWjnuԋ.OխxE^ 5QE%4 V VHӑ@[u{Wt&'ݏi`o wnŨ8r5Kuոa. 1ޚmO߾VNs~Ewp>Я&M' Wo&P$9,~8}RozOݎ[y{3[?s2WG?uCz{c[r !ǁ\hӘwaQtf0EI)OW16T0?D")SD/(!7^%ߠg8]z}R)/i1[#*usմu-=.- NZM|-9pJHyph"Z<ӊN#7fs(Ãkʭy;FPeӌ hcʘux4̺=&Uîf{7lQT13>&ݳ=ӷ҅ܨ]"/C'6gHQܒg8#c̀uT߄y#D7 YDPH'KbZ2t3_ cržXlz}_b7f6{9cYNS]-LZ z.@J;/WDg\m<~ZHn7[Ixo^Q{“*7+uz[)PK!Hg)!random_cli-0.1.2.dist-info/RECORD}˚BP