Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75981
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jeanpierreda@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'example:': 0.03; 'syntax': 0.04; 'string': 0.09; 'falls': 0.09; 'subject:language': 0.09; 'subject:string': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'language.': 0.14; 'random': 0.14; 'template': 0.14; 'expressions?': 0.16; 'subject:generation': 0.16; 'subject:random': 0.16; 'wrote:': 0.18; 'library': 0.18; 'module': 0.19; 'pfxlen:0': 0.19; '>>>': 0.22; 'import': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'paul': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'equivalent': 0.26; 'header :In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'class': 0.32; 'probably': 0.32; 'regular': 0.32; 'fri,': 0.33; "can't": 0.35; 'skip:s 30': 0.35; 'skip:u 20': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'generating': 0.39; 'skip:u 10': 0.60; 'back': 0.62; 'kind': 0.63; 'choose': 0.64; 'to:addr:gmail.com': 0.65; 'secure': 0.71; 'regexp': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=U54v8MvAfYJi2CFf4hwGER48BNEjJCbLO6b3FWBWbuA=; b=d6mGiuPp0sRoiLUsQfc15VAGLUTlvgVJ0JFiKYk4LxEddfPTphqwiUJYC45191Y8yq GiP5wZo84Ro+VUkQ04r0B7Vc9M9g0ASSNsjZa3C5hoCXTD0+eNx+hL0fTKYTapSDVFaQ 4G3K3ZgV4I3ECztFB/1gZpk6FCBe2zaGCLyBkG1/HiwH7XgyWetBYfBcsX0xgSBXD/EY 2NXBJM/Pyy2PkoVKTOnikGqYTjsXWhOWpEC+GfKhvCgJFJXVPDJudmYTudzLBiVldOHZ 10t2Pm72J6x/ziKnJSxhhxv/X58CPwEaXv6X8leonxiK7Erge9O22C7GAOHrTaGqbnrr uC+Q== |
| X-Received | by 10.224.128.9 with SMTP id i9mr55736144qas.50.1407674624687; Sun, 10 Aug 2014 05:43:44 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <14d94692-2257-4dfb-a82f-f1674a839233@googlegroups.com> |
| References | <14d94692-2257-4dfb-a82f-f1674a839233@googlegroups.com> |
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
| Date | Sun, 10 Aug 2014 05:43:04 -0700 |
| Subject | Re: Template language for random string generation |
| To | Paul Wolf <paulwolf333@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | "comp.lang.python" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12817.1407674628.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1407674628 news.xs4all.nl 2832 [2001:888:2000:d::a6]:53210 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75981 |
Show key headers only | View raw
On Fri, Aug 8, 2014 at 2:01 AM, Paul Wolf <paulwolf333@gmail.com> wrote:
> This is a proposal with a working implementation for a random string generation template syntax for Python. `strgen` is a module for generating random strings in Python using a regex-like template language. Example:
>
> >>> from strgen import StringGenerator as SG
> >>> SG("[\l\d]{8:15}&[\d]&[\p]").render()
> u'F0vghTjKalf4^mGLk'
Why aren't you using regular expressions? I am all for conciseness,
but using an existing format is so helpful...
Unfortunately, the equivalent regexp probably looks like
r'(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])[a-zA-Z0-9]{8:15}'
(I've been working on this kind of thing with regexps, but it's still
incomplete.)
> * Uses SystemRandom class (if available, or falls back to Random)
This sounds cryptographically weak. Isn't the normal thing to do to
use a cryptographic hash function to generate a pseudorandom sequence?
Someone should write a cryptographically secure pseudorandom number
generator library for Python. :(
(I think OpenSSL comes with one, but then you can't choose the seed.)
-- Devin
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Template language for random string generation Paul Wolf <paulwolf333@gmail.com> - 2014-08-08 02:01 -0700
Re: Template language for random string generation Chris Angelico <rosuav@gmail.com> - 2014-08-08 19:22 +1000
Re: Template language for random string generation Paul Wolf <paulwolf333@gmail.com> - 2014-08-08 02:42 -0700
Re: Template language for random string generation Ned Batchelder <ned@nedbatchelder.com> - 2014-08-08 07:20 -0400
Re: Template language for random string generation Paul Wolf <paulwolf333@gmail.com> - 2014-08-08 06:02 -0700
Re: Template language for random string generation Chris Angelico <rosuav@gmail.com> - 2014-08-08 21:29 +1000
Re: Template language for random string generation Paul Wolf <paulwolf333@gmail.com> - 2014-08-08 06:03 -0700
Re: Template language for random string generation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-09 00:08 +1000
Re: Template language for random string generation Skip Montanaro <skip@pobox.com> - 2014-08-08 09:35 -0500
Re: Template language for random string generation cwolf.algo@gmail.com - 2014-08-08 11:43 -0700
Re: Template language for random string generation Nick Cash <nick.cash@npcinternational.com> - 2014-08-08 20:28 +0000
Re: Template language for random string generation Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-08 16:03 -0600
Re: Template language for random string generation Paul Wolf <paulwolf333@gmail.com> - 2014-08-08 23:52 -0700
Re: Template language for random string generation Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-09 01:49 -0600
Re: Template language for random string generation Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-09 01:57 -0600
Re: Template language for random string generation Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-08-10 05:43 -0700
Re: Template language for random string generation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-11 02:31 +1000
Re: Template language for random string generation Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-08-10 11:28 -0700
Re: Template language for random string generation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-11 12:22 +1000
Re: Template language for random string generation Chris Angelico <rosuav@gmail.com> - 2014-08-11 12:31 +1000
Re: Template language for random string generation Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-08-11 00:01 -0700
Re: Template language for random string generation Chris Angelico <rosuav@gmail.com> - 2014-08-11 05:25 +1000
Re: Template language for random string generation Paul Wolf <paulwolf333@gmail.com> - 2014-08-10 22:06 -0700
Re: Template language for random string generation Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-11 08:58 +0100
Re: Template language for random string generation Paul Wolf <paulwolf333@gmail.com> - 2014-08-10 09:34 -0700
Re: Template language for random string generation Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-10 10:47 -0600
Re: Template language for random string generation Paul Wolf <paulwolf333@gmail.com> - 2014-08-10 21:56 -0700
Re: Template language for random string generation Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-08-10 11:48 -0700
Re: Template language for random string generation Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-10 10:38 -0600
csiph-web