Re: Template language for random string generation

2014-08-11 Thread Devin Jeanpierre
On Sun, Aug 10, 2014 at 7:22 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Devin Jeanpierre wrote: On Sun, Aug 10, 2014 at 9:31 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't think that using a good, but not cryptographically-strong, random number

Re: Template language for random string generation

2014-08-11 Thread Mark Lawrence
On 11/08/2014 06:06, Paul Wolf wrote: I'm pleased to see that you have answers. In return would you please read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. -- My fellow Pythonistas, ask not what

Re: Template language for random string generation

2014-08-10 Thread Devin Jeanpierre
On Fri, Aug 8, 2014 at 2:01 AM, Paul Wolf paulwolf...@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:

Re: Template language for random string generation

2014-08-10 Thread Steven D'Aprano
Devin Jeanpierre wrote: On Fri, Aug 8, 2014 at 2:01 AM, Paul Wolf paulwolf...@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

Re: Template language for random string generation

2014-08-10 Thread Paul Wolf
On Sunday, 10 August 2014 13:43:04 UTC+1, Devin Jeanpierre wrote: On Fri, Aug 8, 2014 at 2:01 AM, Paul Wolf paulwolf...@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

Re: Template language for random string generation

2014-08-10 Thread Ian Kelly
On Aug 10, 2014 6:45 AM, Devin Jeanpierre jeanpierr...@gmail.com wrote: * 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? You mean in the

Re: Template language for random string generation

2014-08-10 Thread Ian Kelly
On Sun, Aug 10, 2014 at 10:34 AM, Paul Wolf paulwolf...@gmail.com wrote: For instance, a template language that validates the output would have to do frequency analysis. But that is getting too far off the purpose of strgen, although such a mechanism would certainly have its place. I don't

Re: Template language for random string generation

2014-08-10 Thread Devin Jeanpierre
On Sun, Aug 10, 2014 at 9:34 AM, Paul Wolf paulwolf...@gmail.com wrote: * No one will want to write that expression We've already established that one to be wrong. ;) * The regex expression doesn't work anyway That's a cheap swipe. The regexp doesn't work because I used a colon instead of a

Re: Template language for random string generation

2014-08-10 Thread Devin Jeanpierre
On Sun, Aug 10, 2014 at 9:31 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: (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

Re: Template language for random string generation

2014-08-10 Thread Chris Angelico
On Mon, Aug 11, 2014 at 2:31 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Personally, I think even the OP's specified language is too complex. For example, it supports literal text, but given the use-case (password generators) do we really want to support templates like

Re: Template language for random string generation

2014-08-10 Thread Steven D'Aprano
Devin Jeanpierre wrote: On Sun, Aug 10, 2014 at 9:31 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't think that using a good, but not cryptographically-strong, random number generator to generate passwords is a serious vulnerability. What's your threat model? I've

Re: Template language for random string generation

2014-08-10 Thread Chris Angelico
On Mon, Aug 11, 2014 at 12:22 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: You mean the opposite to OpenSSL, which was handed down to Mankind from the Gods? I thought Prometheus stole OpenSSL and gave it to mankind so a group of Minotaurs would stop teasing him about

Re: Template language for random string generation

2014-08-10 Thread Paul Wolf
On Sunday, 10 August 2014 17:47:48 UTC+1, Ian wrote: On Sun, Aug 10, 2014 at 10:34 AM, Paul Wolf paulwolf...@gmail.com wrote: For instance, a template language that validates the output would have to do frequency analysis. But that is getting too far off the purpose of strgen, although

Re: Template language for random string generation

2014-08-10 Thread Paul Wolf
On Sunday, 10 August 2014 17:31:01 UTC+1, Steven D'Aprano wrote: Devin Jeanpierre wrote: On Fri, Aug 8, 2014 at 2:01 AM, Paul Wolf paulwolf...@gmail.com wrote: This is a proposal with a working implementation for a random string generation template syntax for Python. `strgen` is

Re: Template language for random string generation

2014-08-09 Thread Paul Wolf
On Friday, 8 August 2014 23:03:18 UTC+1, Ian wrote: On Fri, Aug 8, 2014 at 3:01 AM, Paul Wolf paulwolf...@gmail.com wrote: * Uses SystemRandom class (if available, or falls back to Random) A simple improvement would be to also allow the user to pass in a Random object That is not a bad

Re: Template language for random string generation

2014-08-09 Thread Ian Kelly
On Sat, Aug 9, 2014 at 12:52 AM, Paul Wolf paulwolf...@gmail.com wrote: On Friday, 8 August 2014 23:03:18 UTC+1, Ian wrote: Have you given any thought to adding a validation mode, where the user provides a template and a string and wants to know if the string matches the template? Isn't

Re: Template language for random string generation

2014-08-09 Thread Ian Kelly
On Sat, Aug 9, 2014 at 1:49 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Sat, Aug 9, 2014 at 12:52 AM, Paul Wolf paulwolf...@gmail.com wrote: On Friday, 8 August 2014 23:03:18 UTC+1, Ian wrote: Have you given any thought to adding a validation mode, where the user provides a template and a

Template language for random string generation

2014-08-08 Thread Paul Wolf
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

Re: Template language for random string generation

2014-08-08 Thread Chris Angelico
On Fri, Aug 8, 2014 at 7:01 PM, Paul Wolf paulwolf...@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. Looks good!

Re: Template language for random string generation

2014-08-08 Thread Paul Wolf
On Friday, 8 August 2014 10:22:33 UTC+1, Chris Angelico wrote: But I eyeballed your code, and I'm seeing a lot of u'string' prefixes, which aren't supported on 3.0-3.2 (they were reinstated in 3.3 as per PEP 414), so a more likely version set would be 2.6+, 3.3+. What's the actual version

Re: Template language for random string generation

2014-08-08 Thread Ned Batchelder
On 8/8/14 5:42 AM, Paul Wolf wrote: On Friday, 8 August 2014 10:22:33 UTC+1, Chris Angelico wrote: But I eyeballed your code, and I'm seeing a lot of u'string' prefixes, which aren't supported on 3.0-3.2 (they were reinstated in 3.3 as per PEP 414), so a more likely version set would be 2.6+,

Re: Template language for random string generation

2014-08-08 Thread Chris Angelico
On Fri, Aug 8, 2014 at 9:20 PM, Ned Batchelder n...@nedbatchelder.com wrote: On 8/8/14 5:42 AM, Paul Wolf wrote: On Friday, 8 August 2014 10:22:33 UTC+1, Chris Angelico wrote: But I eyeballed your code, and I'm seeing a lot of u'string' prefixes, which aren't supported on 3.0-3.2 (they were

Re: Template language for random string generation

2014-08-08 Thread Paul Wolf
On Friday, 8 August 2014 12:20:36 UTC+1, Ned Batchelder wrote: On 8/8/14 5:42 AM, Paul Wolf wrote: Don't bother trying to support =3.2. It will be far more difficult than it is worth in terms of adoption of the library. Also, you don't need to write a proposal for your library.

Re: Template language for random string generation

2014-08-08 Thread Paul Wolf
On Friday, 8 August 2014 12:29:09 UTC+1, Chris Angelico wrote: Debian Wheezy can spin up a Python 3 from source anyway, and presumably ditto for any other Linux distro that's distributing 3.1 or 3.2; most other platforms should have a more modern Python available one way or another.

Re: Template language for random string generation

2014-08-08 Thread Steven D'Aprano
Paul Wolf 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

Re: Template language for random string generation

2014-08-08 Thread Skip Montanaro
One suggestion, though perhaps nothing actually needs changing. I occasionally run into sites which define their password constraints as something like minimum 8 characters, at least one number, one uppercase letter, and one special character. Their notion of special (which in my mind means any

Re: Template language for random string generation

2014-08-08 Thread cwolf . algo
On Friday, August 8, 2014 10:35:12 AM UTC-4, Skip Montanaro wrote: One suggestion, though perhaps nothing actually needs changing. I occasionally run into sites which define their password constraints as something like minimum 8 characters, at least one number, one uppercase letter, and

Re: Template language for random string generation

2014-08-08 Thread Ian Kelly
On Fri, Aug 8, 2014 at 3:01 AM, Paul Wolf paulwolf...@gmail.com wrote: * Uses SystemRandom class (if available, or falls back to Random) A simple improvement would be to also allow the user to pass in a Random object, in case they have their own source of randomness they want to use, or for fake

Re: Template language for random string generation

2014-08-08 Thread Nick Cash
On 08/08/2014 01:45 PM, cwolf.a...@gmail.com wrote: On Friday, August 8, 2014 10:35:12 AM UTC-4, Skip Montanaro wrote: P.S. Probably a topic for a separate thread, and not actually Python-related, but on a related note, I have never found a free password keeper which works on all my