I'm currently building a website where the users would enter their credentials for another web service that I'm going to scrape to get their data.
I want to make sure that when I save their credentials in my database, I'm using the best encryption possible and the best architecture pattern to ensure the highest level of security.
The first idea that I had in mind was to encrypt the data using an RSA pub key (PBKDF2, PKCS1_OAEP, AES 256bit... ???) and then allowing my scrapping script to use the private key to decrypt the credentials and use them.
Could you recommend the right/best encryption to do this?
If my server is hacked, the hacker would have access to both the database and the private key, since it will be kept on my server that runs the scrapping script and hosts the DB. I know that it's a difficult equation to solve. But maybe there is an architecture pattern that helps with this.
I'm coding in python and I believe PyCrypto is the go-to library for encryption. (Sorry I have very little knowledge about cryptography so I might be confusing technologies)
EDIT:
I'm also looking to find out how to design my server(s) to secure all this. I know that if I use RSA, I need to put my private key somewhere where it won't be reachable from internet if my server is compromised, but still the private key needs to be reachable by my scrapping script that needs internet access.
So as you can see i'm a bit lost. I'm ready to use two independant servers but I don't have any idea about the best system design to use here.
Many thanks.
…then allowing my scrapping script to use the private key…
– To clarify: you are planning to store that private key on the same (internet-connected) server you’re going to run the script on? If the answer is “yes”, how are you planning to handle potential server breaches which might give adversaries easy access to your private key (which – if you handle things the wrong way – could void most of your security efforts)? Therefore, it would be great if you could edit your question, describing that part of your plan too… thanks. $\endgroup$