When using a container in Kubernetes, I prefer to use a shell command to complete the task instead of writing a python script since the shell commands are usually much simpler and intuitive.
If I want to encrypt a string “helloworld”, it could be accomplished by:
echo helloworld | openssl aes-256-cbc -a -salt -pbkdf2 -pass pass:mypassword
The ‘mypassword’ is the real password for encryption.
To decrypt, I could just use
echo U2FsdGVkX1+SWVzJK6Ji7DJ77r/U9XxyxNqDXrxZ6ck= | openssl aes-256-cbc -d -a -pbkdf2 -pass pass:mypassword