In this blog, I have explained the process of securing password using Encryption and Decryption in SQL
Open SQL Server and create database and table as you do normally.
In stored procedure, we have to declare the variable (Password) which should be Encrypted and Decrypted.
To encrypt the word used in password, write the query given below.
- Declare @Encrypt varbinary(200)
- Select @Encrypt = EncryptByPassPhrase(‘key’, ‘Jothish’ )
- Select @Encrypt as Encrypt
To decrypt the word used in password, write the query given below.
- Select convert(varchar(100),DecryptByPassPhrase(‘key’,@Encrypt )) as Decrypt
As a result, the password has been encrypted and decrypted in SQL SP. The below image shows the working of the code.