Password Encryption And Decryption In SQL SP

In this blog, I have explained the process of securing password using Encryption and Decryption in SQL Stored Procedure.
 
STEP 1

Open SQL Server and create database and table as you do normally.

STEP 2

In stored procedure, we have to declare the variable (Password) which should be Encrypted and Decrypted.
 
STEP 3

To encrypt the word used in password, write the query given below.
  1. Declare @Encrypt varbinary(200)  
  2. Select @Encrypt = EncryptByPassPhrase('key''Jothish' )  
  3. Select @Encrypt as Encrypt  
STEP 4

To decrypt the word used in password, write the query given below.
  1. Select convert(varchar(100),DecryptByPassPhrase('key',@Encrypt )) as Decrypt   
STEP 5

As a result, the password has been encrypted and decrypted in SQL SP. The below image shows the working of the code.
 
               
 
Hope, this blog will help you.