I am encrypting password using SHA2_256 hashbytes converter in SQL; now I want to see the orginal data

37 Views Asked by At

I tried this to convert data into encrypted data,

INSERT INTO userDetails (role, userName, name, password, statusId, isDeleted)
VALUES (@role, @username, @name,
        HASHBYTES('SHA2_256', @password COLLATE SQL_Latin1_General_CP1_CS_AS), 
        @status, 0) 

The original data is '1234' but when I try this below code to retrieve the original data it returns

'18B84AE5B24E651842D52B8FC8E9FEF04BAB9E3169AE7A3D444BE7E691F9A2AF'

I tried this:

SELECT 
    CONVERT(VARCHAR(256), HASHBYTES('SHA2_256', password), 2) AS password  
FROM userDetails

How to get the original data of HASHBYTES 'SHA2_256' converted data?

1

There are 1 best solutions below

3
Włodzimierz O. Kubera On

Hash is rather a one way processing, however it looks like you have:

SELECT password FROM userDetails