Generate a file containing a random string of text, then encrypt it
Calculate the sha256 checksum of the encrypted file and store it in a database. Then provide the file and the decryption key to the user for download.
When the user wants to login, they upload that file to my server in a buffer, where the sha256 is calculated and checked against the database. If it matches, user gains access to their account data, associated with the checksum. If it doesnt, the file is rejected. Either way, the encrypted file is deleted after checking.
I think this would be really secure because if my server is compromised, the only thing an attacker would have is sha256 checksums as user identifiers. I know there's probably hashing/file-handling attack vectors, as well as file-collision scenarios(although rare, still possible)
Are there any additional considerations I should take into account with this project? Also, security QA's as recovery in case they lose their file.
2. You should always "salt" stored password hashes. https://en.wikipedia.org/wiki/Salt_(cryptography)
3. I think you should look at resources like https://www.vice.com/en/article/wnx8nq/why-you-dont-roll-you... https://security.stackexchange.com/questions/18197/why-shoul... https://www.infosecinstitute.com/resources/cryptography/the-... to examine the arguments against trying to develop your own security schemes as someone with less experience in this space.
If it's random, why do you need to encript it?
> When the user wants to login, they upload that file to my server in a buffer, where the sha256 is calculated and checked against the database. [...] Either way, the encrypted file is deleted after checking.
This is exactly like the standard method to login users. You don't store the password in the server, you only stored a hash of the password. Why are you proposing to use sha256 instead of bcrypt or scrypt?
see how mullvad does it