Python Forum
Best way to secure API key when sharing - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Best way to secure API key when sharing (/thread-41459.html)



Best way to secure API key when sharing - quarinteen - Jan-19-2024

Hello I have a script that has an api key in it in plain text. This has been okay because only myself and 1 other person uses it. I have been asked to share it though. With that I need to hide the api key and secret. What is the best method of doing this so I can share the script with others? The ways I have found are below. None of these really seem like good ways to me though besides the encrypted file. I can not figure out how to get an encryption key though. Any suggestions would be appreciated. Thank you.

1. Use an encrypted file
2. Use environment variables
3. Code Obfuscation


RE: Best way to secure API key when sharing - rob101 - Jan-19-2024

Why don't you simply replace the key/secret with something like <key> <secret> and explain that the user needs to insert their own there?


RE: Best way to secure API key when sharing - deanhystad - Jan-19-2024

You could make an executable.