Revisión 147
Añadido por Manu Mora Gordillo hace alrededor de 14 años
Utils.py | ||
---|---|---|
string = string.replace("ñ","n").replace("Ñ","N")
|
||
|
||
return string
|
||
|
||
def generate_salt():
|
||
# Salt can be any length, but not more than about 37 characters
|
||
# because of limitations of the binascii module.
|
||
# 7 is what Netscape's example used and should be enough.
|
||
# All 256 characters are available.
|
||
from random import randrange
|
||
|
||
salt = ''
|
||
for n in range(7):
|
||
salt += chr(randrange(256))
|
||
return salt
|
||
|
||
def encrypt(password):
|
||
import sha
|
||
from binascii import b2a_base64
|
||
|
||
password = str(password)
|
||
salt = generate_salt()
|
||
|
||
return b2a_base64(sha.new(password + salt).digest() + salt)[:-1]
|
Exportar a: Unified diff
Cifrado de password SSHA