I am creating a software with user + password. After autentification, the user can access some semi public services, but also encrypt some files that only the user can access.
The user must be stored as is, without modification, if possible. After auth, the user and the password are kept in memory as long as the software is running (i don't know if that's okay either).
The question is how should i store this user + password combination in a potentially unsecure database?
I don't really understand what should i expose.
Let's say I create an enhanced key like this:
salt = random 32 characters string (is it okay?) key = hash(usr password + salt) for 1 to 65000 do key = hash(key + usr password + salt)
Should I store the [plaintext user], [the enhanced key] and [the salt] in the database ?
Also, what should I use to encrypt (with AES or Blowfish) some files using a new password everytime ? Should I generate a new salt and create a new enhanced key using (the password stored in memory of the program + the salt) ? And in this case, if i store the encrypted file in the database, i should probably only store the salt. The database is the same as where i store the user + password combination.
The file can only be decrypted if someone can generate the key, but he doesn't know the password. Right ?
I use Python with PyCrypto, but it's not really important, a general example is just fine. I have read a few similar questions, but they are not very explicit.
Thank you very very much!