In Sql Server 2005 what data type should be used to store passwords hashed by SHA-256 algorithm?
The data is hashed by the application and passed to the database
In Sql Server 2005 what data type should be used to store passwords hashed by SHA-256 algorithm?
The data is hashed by the application and passed to the database
Should produce a 32-byte value (256 bits), so binary(32) ought to work.
The "Hash" attribute of the SHA256Managed class is an array of bytes, and HashSize is 256 bits, so I believe a binary(32) would be the simplest.
You could probably also put it into a varchar field using the ToBase64Transform. I'm not completely familiar with the Base64 Algorithm, but It seems like you would need probably need at least 43 characters to represent a 256 bit number in base 64. IIRC Base64 uses a couple padding characters, so I'd probably put it at varchar(50) just to be safe.
SHA-256 has a 256 bit output
256bits = 32 Bytes
So try varbinary(32)
I prefer to convert the hash-Code to an Hex-String in this case a varchar(64) will do the trick or an varchar (66) if you like a "0x
"-prefix. In this way it is much easier to compare manually or (re)set values you have to copy/paste from other places. e.g you lost your admin-PW and want to reset it via SQL...