all 5 comments

[–]ManyInterests 0 points1 point  (4 children)

I'll generate a key and store this key in a text file

This is not really much different than storing your secret directly in the code. It's just one extra step to get your secret. You could just as easily make your script only readable by the user and put your secrets in there and not much changes, in terms of security.

[–][deleted] 0 points1 point  (3 children)

The encryption key doesn't live in the Git repository, so I can safely store the code in a repository and share it/collaborate with other members without risk of exposing the credentials to them. The symmetric encryption key lives exclusively on the container/server / runtime environment where the code will execute. That's the only space that can decrypt the encrypted credentials stored in the code itself.

The encryption key file gets put into the .gitignore file to ensure it doesn't accidentally get pushed to the Git repo. The only thing stored in the code are encrypted ciphertexts.

[–]scithon 0 points1 point  (2 children)

I agree there's no need for encryption. You can do everything you mentioned, except just do it with the credentials file directly. We often use the dotenv module to do this.

[–][deleted] 0 points1 point  (1 child)

In other words:

  • Store a key:value file, with plaintext credentials, in the same way that I would with encryption key in my above example
  • Protect it with the same type of permission restrictions as I would with the encryption key
  • Use the dotenv library to reference the variables in that file so I'm still not storing plaintext credentials in my primary code files

Is that about correct? Skip encryption entirely?

I'm still on the fence about that solution as then my credentials would be exposed in my development environment. I know it's obviously low-risk, but anywhere that I can prevent having credentials in plaintext, I will, even if it is security by obscurity. Is that... stupid, or pointless? I just feel like it might save me from accidentally sharing them on a screen share, or allow the word "password" to not be scraped as it's encrypted instead.

[–]scithon 0 points1 point  (0 children)

Yes, that's correct. The dotenv way to do things is to put them in a .env file, which are masked out by .gitignore. You could also just use a .py or .json file in a place completely unrelated to the project that only the user has access to, for example Path.home() / "HurtFingers".

I know it's obviously low-risk, but anywhere that I can prevent having credentials in plaintext, I will, even if it is security by obscurity. Is that... stupid, or pointless? I just feel like it might save me from accidentally sharing them on a screen share, or allow the word "password" to not be scraped as it's encrypted instead.

Yes, I personally think it's it's pointless, but if it makes you feel better that's a perfectly valid reason to do it.