I have bankAccountnumber and routing number stored in SQL Server.
How I can encrypt those information most secure way?
What datatype I should use?
I want to use Hashcode with salt but I do not know how to decrypt?
SQL Server table
Salt varbinary(250) not null
bankAccountnumber binary(16) not null
Code
For encryption below code work but I do not know how to decrypt bankaccount number. I do not know I am using right datatype.
public void CreateNewAccount(AccountManagementView userAccount)
{
byte[] salt = System.Text.Encoding.UTF8.GetBytes("hereissalt");
byte[] hashedbankaccnumber = CreateSaltedField(salt, userAccount.bankAccountnumber);
BuildInsertQueryForTable("User")
.SetColumnToValue("ID", Guid.NewGuid())
.SetColumnToValue("EmailAddress", userAccount.EmailAddress)
.SetColumnToValue("Salt", salt)
.SetColumnToValue("bankAccountnumber", hashedbankaccnumber )
.ExecuteNonQuery();
}
This is function generating encryption key
private static byte[] CreateSaltedField(byte[] salt, string bankAccountnumber)
{
return new HMACMD5(salt).ComputeHash(System.Text.Encoding.UTF8.GetBytes(bankAccountnumber));
}
Can anybody help me?