[Tutor] Convert os.random output to a string

Jay Lozier jslozier at gmail.com
Fri Mar 7 01:43:37 CET 2014


Alan

I am planning to store the passwords encrypted. This part is allow a 
user to generate and view the generated password.

Ben got me pointed to a snippet I can use. I was trying to do something 
the hard way.

Jay
On 03/06/2014 07:34 PM, Alan Gauld wrote:
> On 06/03/14 23:32, Jay Lozier wrote:
>
>> I am try to generate random password strings of an arbitrary user
>> selected length. I read to generate a random string of a user supplied
>> length I can use os.urandom(n).
>
> So far so good...
>
> > I want to convert the output to a human readable string.
>
> Define human readable?
>
>> I would like to store the string for later processing.
>
> Depending on the application there may be laws/rules/guidance 
> prohibiting the storage of passwords. Best practice only ever
> stores the encrypted form not the original password (or more
> properly nowadays pass-phrase since phrases are more secure
> than words.)
>
>> Also, I would like to limit the characters to the US keyboard, so I
>> might be using the wrong function.
>
> Even in the US not everyone uses a "US keyboard" especially nowadays 
> with various tablets/phablets/phones in use. but if you stick to the 
> printable subset of the old ASCII set you should be close enough...
> But that probably means building your own random generator based
> on the subrange of characters.
>
>> I am probably missing something very obvious.
>
> Maybe, or you could be asking for more than the library gives?
>

-- 
Jay Lozier
jslozier at gmail.com



More information about the Tutor mailing list