Storing secure information

What is the best way to store secure information on the gateway? For example, if a password for an e-mail account needs to be stored.

Private key encryption would be the easiest but then where do you store the private key? Public key encryption will require internet access to a public key store, which won’t always be available since they gateway could be on a LAN.

Are there any python libraries that could help? I found a few but they seem to be outdated/abandoned.