0

I have a column with password_hash in this when user enter something in textbox from page then this convert to this form in the SQL Server table.

For example, if the user enters 4512, then it is converted to this form:

90 119 218 156 223 147 36 245 171 86 241 32 174 66 192 226 34 75

How do I decrypt this with a T-SQL query?

Any solution ?

Lukasz Szozda
  • 162,964
  • 23
  • 234
  • 275
  • 5
    You can't decrypt hash (it is one way function). Of course you could try to brute force it. Please describe what are you trying to achieve (compare hashes/extract original value/...) – Lukasz Szozda Aug 09 '17 at 11:38
  • i am achieve 4512 value from hash which i mentioned through SQL query – user progam Aug 09 '17 at 11:44
  • 1
    If it is real hash (MD5, SHA...) you simply won't be able to do it. – Lukasz Szozda Aug 09 '17 at 11:46
  • any possibilities ? and i am using Dim sha As SHA256 = New SHA256Managed() on code – user progam Aug 09 '17 at 11:56
  • Why would you want to do that? If the reason is beyond breaking someone's password, then maybe whatever problem you are trying to solve can be approached differently. – InitK Aug 09 '17 at 12:03

2 Answers2

1

You really can't, but if you want to try and guess it use this:

SELECT name FROM sys.sql_logins   
WHERE PWDCOMPARE('EnterPasswordHere', password_hash) = 1 ;  

It returns only those with that password.

1

any possibilities ? and i am using Dim sha As SHA256.... <= No, the purpose of a hash is to provide one way encryption. You encrypt but can't decrypt. See also SO - Fundamental difference between Hashing and Encryption algorithms

What you actually want to do is to create a hash of the entered password and compare that to the stored password hash to see if they are equal. Then you know if the entered password matches the stored password.

Igor
  • 60,821
  • 10
  • 100
  • 175