Le Mon, 26 Dec 2011 18:28:55 +0100,
Cédric Krier <[email protected]> a écrit :

> Is uuid large enough for the authentication key?
> 
>     http://docs.python.org/library/uuid.html
> 

As uuid is designed for uniqueness and not security, it depends
partially on the current time, which is a weakness in this kind of
usage. I propose this:

import string
import random
ALPHABET = string.letters + string.digits

def token(length=22):
    return ''.join(map(
            lambda x: random.choice(ALPHABET),
            xrange(length))
                   )

IIRC a length of 22 give the same order of combinations than uuid.


-- 

Bertrand Chenal

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email: [email protected]
Website: http://www.b2ck.com/

-- 
[email protected] mailing list

Reply via email to