Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(8)  |  Call(5)  |  Derive(0)  |  Import(3)

        def md5_hash(image=None, max_length=None):
    # TODO:  Figure out how much entropy is actually needed, and reduce the current number of bytes if possible if doing
    # so will result in a performance improvement.
    if max_length:
        assert max_length > 0

    ret = hashlib.md5(image or os.urandom(224)).hexdigest()
    return ret if not max_length else ret[:max_length]
        


src/d/j/django-common-helpers-0.6.0/django_common/db_fields.py   django-common-helpers(Download)
 
from south.modelsinspector import add_introspection_rules
from django_common.helper import md5_hash
 
 
    def __init__(self, update_on_save=False, hash_length=None, *args, **kwargs):
        #TODO: args & kwargs serve no purpose but to make django evolution to work
        self.update_on_save = update_on_save
        self.hash_length = hash_length
        super(fields.CharField, self).__init__(max_length=128, unique=True, blank=False, null=False, db_index=True, default=md5_hash(max_length=self.hash_length))
    def pre_save(self, model_instance, add):
        if not add and not self.update_on_save:
            return getattr(model_instance, self.name)
 
        random_hash = md5_hash(max_length=self.hash_length)

src/d/j/django-common-HEAD/django_common/db_fields.py   django-common(Download)
 
from south.modelsinspector import add_introspection_rules
from django_common.helper import md5_hash
 
 
    def __init__(self, update_on_save=False, hash_length=None, *args, **kwargs):
        #TODO: args & kwargs serve no purpose but to make django evolution to work
        self.update_on_save = update_on_save
        self.hash_length = hash_length
        super(fields.CharField, self).__init__(max_length=128, unique=True, blank=False, null=False, db_index=True, default=md5_hash(max_length=self.hash_length))
    def pre_save(self, model_instance, add):
        if not add and not self.update_on_save:
            return getattr(model_instance, self.name)
 
        random_hash = md5_hash(max_length=self.hash_length)

src/t/i/tivix-django-braintree-0.1.3/django_braintree/forms.py   tivix-django-braintree(Download)
from django import forms
 
from django_common.helper import md5_hash
from braintree import Customer, CreditCard
from django_braintree.models import UserVault
 
        # in case the above updating fails or user was never in the vault
        new_customer_vault_id = '%s%s' % (prepend_vault_id, md5_hash()[:24])
        respone = Customer.create({    # creating a customer, but we really just want to store their CC details
            'id': new_customer_vault_id,   # vault id, uniquely identifies customer. We're not caring about tokens (used for storing multiple CC's per user)