Dimitris Kougioumtzis Blog About technology

Encrypted pk in django

Category Django

Posted on Dec. 28, 2017



Encrypted pk in django


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import hashlib
from django.db import models

class Encryptedhash(models.Model):
    encrypted_pk = models.CharField(blank=True, max_length=255)

    class Meta:
        abstract = True

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)
        m = hashlib.sha224("{}".format(self.pk).encode('utf-8')).hexdigest()
        self.encrypted_pk = m
        super().save(*args, **kwargs)

About

My name is Dimitris Kougioumtzis and i work as a Web developer at Rapidbounce Company

Elsewhere