Skip to content

Instantly share code, notes, and snippets.

@timbroder
Created February 14, 2013 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timbroder/4955981 to your computer and use it in GitHub Desktop.
Save timbroder/4955981 to your computer and use it in GitHub Desktop.
def save(self,*args,**kwargs):
self.response = self.response.lower()
if not self.expiration:
self.expiration = datetime.datetime.now() + datetime.timedelta(minutes= int(captcha_settings.CAPTCHA_TIMEOUT))
if not self.hashkey:
key_ = unicodedata.normalize('NFKD', str(randrange(0,MAX_RANDOM_KEY)) + str(time.time()) + unicode(self.challenge)).encode('ascii', 'ignore') + unicodedata.normalize('NFKD', unicode(self.response)).encode('ascii', 'ignore')
if hashlib:
self.hashkey = hashlib.new('sha', key_).hexdigest()
else:
self.hashkey = sha.new(key_).hexdigest()
del(key_)
super(CaptchaStore,self).save(*args,**kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment