Decrypt Encrypted Password

SQL:
select HASHBYTES('SHA2_512', N'joseph')
     , convert(varchar(512), HASHBYTES('SHA2_512', N'joseph'), 2)
 
I just gave it a try, and this is the result I got.

0x24D6EDB8DBE2BCA27CFEFC1B0682BB7C34A0F5AA23EC6EA2724CC0DBFDBB9EB3D6BC90FEA92B84C0820DB784319ED53E6FB5DE74B19C36FEDE0C594D374792CD
I also experimented a little more, and I think you will be fine.

1722017283015.png
 
varchar:
HASHBYTES('SHA2_512', 'joseph') => 0x24D6EDB8DBE2BCA...

nvarchar:
HASHBYTES('SHA2_512', N'joseph') => 0x866D9B1682FB5DB56DDD86...

Different input generates different output. ;)
 
I see, so what do you get if you simply do something like?
Code:
 SELECT HASHBYTES('SHA2_512','joseph')
Just curious...
I get what I would expect:
0x24D6EDB8DBE2BCA27CFEFC1B0682BB7C34A0F5AA23EC6EA2724CC0DBFDBB9EB3D6BC90FEA92B84C0820DB784319ED53E6FB5DE74B19C36FEDE0C594D374792CD
 
I get what I would expect:
0x24D6EDB8DBE2BCA27CFEFC1B0682BB7C34A0F5AA23EC6EA2724CC0DBFDBB9EB3D6BC90FEA92B84C0820DB784319ED53E6FB5DE74B19C36FEDE0C594D374792CD
Yes, we all get the same thing, and I think @Josef P. already clarified why that is. Thanks.

1722019128871.png
 
Yes. That's it. Thank you! One more question.
Why doesn't this work? This is how I would validate the user, correct?

select LoginName from [dbo].[user]
where PasswordHash = '0x866D9B1682FB5DB56DDD860C95D03447B7120B8E66481DA9FE65AC1FA85C0BEB36F0D1C653E3EE97E832C0D753263CBC8140CAD3F0881921A5E18DC8D93DE541'
 
select LoginName from [dbo].[user]
where PasswordHash = '0x866D9B1682FB5DB56DDD860C95D03447B7120B8E66481DA9FE65AC1FA85C0BEB36F0D1C653E3EE97E832C0D753263CBC8140CAD3F0881921A5E18DC8D93DE541'
This didn't work because I put tics at the beginning and end. I removed the single quotes and now everything is working as it should.
I can't thank you guys enough! I'm new to encryption and this was quite a challenge for me!
 

Users who are viewing this thread

Back
Top Bottom