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

后端 未结 5 846
遥遥无期
遥遥无期 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:46

    If you want an easy-to-use but highly customisable key generator, use key-generator pypi package.

    Here is the GitHub repo where you can find the complete documentation.

    Here's an example:

    from key_generator.key_generator import generate
    
    custom_key = generate(2, ['-', ':'], 3, 10, type_of_value = 'char', capital = 'mix', seed = 17).get_key()
    print(custom_key)  # ZLFdHXIUe-ekwJCu
    

    Hope this helps :)

    Disclaimer: This uses the key-generator library which I made.

提交回复
热议问题