Skip to content Skip to sidebar Skip to footer

Hashing Password Into Sql

I'm hashing a password in SQL directly like this : DECLARE @HashThis nvarchar(4000); SET @HashThis = 'SecretPizza' INSERT into Users (UserId,Password) Values ('CryptTest',HASHBYTE

Solution 1:

Question 1: You get "Chinese like" characters because you are inserting a varbinary value returned by HASHBYTES into an nvarchar column, so SQL Server is trying to interpret the bytes as Unicode code points (characters).

Question 2: Not supported before SQL Server 2012 - see SQL Server 2008 R2 HASHBYTES SHA2 returns null

Solution 2:

first do

select HASHBYTES('SHA2-256', @HashThis) from dual;

and see what you get..

Post a Comment for "Hashing Password Into Sql"