You can use the same method that django uses I've tried it and it
works
in your model inside the class for example users and after the
definitions of the fields
write
def save(self):
raw_password = self.password
import random
algo = 'sha1'
salt = get_hexdigest(algo, str(random.random()), str
(random.random()))[:5]
hsh = get_hexdigest(algo, salt, raw_password)
password = '%s$%s$%s' % (algo, salt, hsh)
self.password = password
super(yourclass,self).save()
or there is another method like this.
but I don't like so much
def _get_ssn(self):
enc_obj = Blowfish.new( settings.SECRET_KEY )
return u"%s" % enc_obj.decrypt( binascii.a2b_hex
(self.password) ).rstrip()
def _set_pass(self, ssn_value):
enc_obj = Blowfish.new( settings.SECRET_KEY )
repeat = 8 - (len( ssn_value ) % 8)
ssn_value = ssn_value + " " * repeat
password = binascii.b2a_hex(enc_obj.encrypt( ssn_value ))
return password
sspass = property(_get_ssn)
def save(self):
self.password = self._set_pass(self.password)
super(Usuario,self).save()
with the last method you need to add this from Crypto.Cipher import
Blowfish
and you have to install Crypto.Cipher.
I hope you solve your problem
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---