Whats the simplest and safest method to generate a API KEY and SECRET in Python

后端 未结 5 844
遥遥无期
遥遥无期 2020-12-15 04:00

I need to generate a API key and Secret that would be stored in a Redis server. What would be the best way to generate a key and secret?

I am develop a Django-tastyp

5条回答
  •  太阳男子
    2020-12-15 04:52

    you can also use following module to generate random string

     1 - os.urandom(64).encode('hex') #from os module
     2 - uuid.uuid4()                 # from uuid module
     3 - get_random_string(length=32) #from django.utils.crypto
     4 - secrets.token_hex(64)         #from secrets >= python 3.6 
    

提交回复
热议问题