I want to store login and password in sqlite database. This database in encrypted using SQLCipher library. But password to encrypt database is separate issue. This password is stored in code of application. Login and password are provided by user to login to application. In C# there is the SHA256 class. If I use this class if it is enough ? Or rather I should use hash and salt or other methods ?
Thanks
To store a user password in a database for login matters, you should use a hash function with a salt.
SHA 256is one of them, but there are better ones existing. I recommend you using thePBKDF2derivative function. You can implement your ownPBKDF2hashing method using theRfc2898DeriveBytesclass provided in the .NET framework.Here is a quick how-to-do-it:
You just have now to store the salt and the hash in your database. Use
Convert.FromBase64StringandConvert.ToBase64Stringto get astringfrom abyte[]and vice-versa.Another alternative is to use
bcrypt. See this interesting article.