Dica 6 - Geradores de senhas randômicas - uuid, hashids, secrets

arrow-up-right

6.1 - uuid

https://docs.python.org/3/library/uuid.html

import uuid

uuid.uuid4()

uuid.uuid4().hex
# models.py
import uuid

from django.db import models


class UuidModel(models.Model):
    slug = models.UUIDField(unique=True, editable=False, default=uuid.uuid4)

    class Meta:
        abstract = True

class Category(UuidModel):
    title = models.CharField('título', max_length=50, unique=True)
    ...

6.2 - shortuuid

arrow-up-right

https://pypi.org/project/shortuuid/

6.3 - hashids

https://gist.github.com/rg3915/4684721a603cf6d0dd3b9495744482fe

https://pypi.org/project/hashids/

django-hashid-field

https://pypi.org/project/django-hashid-field/

https://www.howtogeek.com/howto/30184/10-ways-to-generate-a-random-password-from-the-command-line/

Gerando senhas no terminal Linux

Gerando senhas com Python

com random

com random e string

https://pynative.com/python-generate-random-string/

com secrets

https://docs.python.org/3/library/secrets.html

New in Python 3.6

Django

Last updated