Proyecto

General

Perfil

« Anterior | Siguiente » 

Revisión 147

Cifrado de password SSHA

Ver diferencias:

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