Skip to main content

EncryptByPassPhrase and DecryptByPassPhrase in sql server





This Article explains you how to Encrypt and Decrypt a text in sql server

EncryptByPassPhrase:



Syntax: ENCRYPTBYPASSPHRASE('PASSPHRASE',‘text’)

creating table Login table

create table login(id int identity(1,1),username varchar(10),password varchar(100))


 insert into login (username,password)values('Ramprasad',EncryptByPassPhrase('12','AAA'))
 insert into login (username,password)values('venkat',EncryptByPassPhrase('12','BBB'))
 insert into login (username,password)values('hemanth',EncryptByPassPhrase('12','CCC'))

select * from login

id username         password
1 Ramprasad        
2 venkat                
3 hemanth                

now we are not able to see the passwords .To visible the Passwords we need to Decrypt the passwords

DecryptByPassPhrase:


     DecryptPassPhrase takes two parameters one is 'PASSPHRASE'and text or column_name

select id,username,convert(varchar(10), DECRYPTBYPASSPHRASE ('12',password)) from login

 id
 username
  (Password)
 1
 Ramprasad  
  AAA
 2
 venkat
  BBB
 3
 hemanth
  CCC


Comments

Popular posts from this blog

How to create task scheduler in C#

Today I will elucidate about undertaking scheduler in c# and how to booked on particular time in window.Today i will make an errand scheduler utilizing c# reassure application to call or expend rest web programming interface with intermediary to get information from sharepoint .This illustration use to devour web programming interface to call sharepoint to download report on neighborhood application catalog. How to make Task scheduler in c# application? Step 1:- Create a reassure application in c# Step 2:- You have to include Microsoft.SharePoint.Client library from chunk bundle in you application. utilizing System; utilizing System.IO; utilizing System.Net; utilizing System.Net.Http; utilizing System.Net.Http.Headers; utilizing System.Threading.Tasks; utilizing System.Configuration; utilizing System.Security; utilizing Microsoft.SharePoint.Client; namespace InsightTaskSchedular{ class Program { static void Main() { attempt { /to validate from share

Insert multiple rows at a time in sql server

Insert multiple rows at a time in sql server synatax: insert into @extable(id,firstname,lastname) values(val1,val2,val3), (val4,val5,val6) example declare   @ extable  table ( id   int , firstname   varchar ( 50 ), lastname   varchar ( 50) insert   into   @ extable ( id , firstname , lastname ) values (1 , 'krishna' , 'kumar' ), (2 , 'kalyan' , 'goud' ), (3 , 'praveen' , 'kumar' ) select * from   @extable