0% found this document useful (0 votes)
4 views3 pages

SQL Server 2008 Encryption Guide

The document provides instructions on how to encrypt and decrypt passwords in SQL Server 2008 using specific functions. It includes SQL commands to create a database, a user table, and functions for encryption and decryption of passwords. The document also demonstrates how to insert encrypted data and retrieve it in a decrypted format.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

SQL Server 2008 Encryption Guide

The document provides instructions on how to encrypt and decrypt passwords in SQL Server 2008 using specific functions. It includes SQL commands to create a database, a user table, and functions for encryption and decryption of passwords. The document also demonstrates how to insert encrypted data and retrieve it in a decrypted format.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Onh

tosiccaosin
w
Ish
,liowyouanencrypoitnanddecrypoitnaglorh
timniSQLServer2008.
[Link]
new
.qyauertiveg2ianS
v0oderpq8noltnyedou,tsrFi-1.

eablt testandabesdataeC
-eatr2.

Ascanbeseenintheusertableth,epasswordisavarbinaryof500a,ndthereasonswhywhenthe
ereatgrsioniyenpcrthetbyedw
psgatenhrdorthattdavoihdsoultiandsmerahctesm
arntygenrgioraloniyT enpcrthe
delifhetnipsacewhat
eToeathnF
O
criu-nT
hctm
[Link]
A
iygnpocrtl

varavesecirtihattedatapecirbecanthim tgio,ralhetofniunfcthetnI
oofuevlaheteortsotezisgrealahw teibalivrahnareoteradlcehntnadm ,slla
[Link]
orfkeyaam ,psare2etvseciw
rchohni,iyenpcrtow
rS
fvQ
edroesrLauesoniyenpcrt
w hsepydantyorepctnrec
ENCRYPTBYPASSPHRASEk)('e@
H
ly,'ialc
belw lihtaw
tdaorsi kye'het' htatocuantontikaetesapl
netgotorf
eToeathnFOcriu-nT cthf4m
.oeD
ntA
iygpoecrtl
Hehtrevesrpeorceosenfcyrpoidtsniohntaerl,adyencyrpetdpaswodrhotcefoulmnpoasibsantied.
yenpcrtowvtedresorSQ
verhansoL
thwtedyenpicrtsiandeablivarzeisgearlhetofam pareet
DECRYPTBYPASSPHRASEk('e)@ vay,' lc
w
psahdeortandeyenpcrtsi tw ihcw khteyiheit ueds,beotw am
pstareoestrequriosalhatt
deyptnrec
Next, it will be shown how it will be.
'dbo.'xifeprhethw toniiuntcfhet llaw ckeshit

oyptrcninessam
sepltceleunsnangdoi

Now
otsh,owhtepaswodro,hteoflwnig

SUMMARIZEHEREEVERYTHINGWEWRITESTEPBYSTEPTODOTHEEXERCISE
create database prueba1;
use test1
create table user
(
user_id int primary key,
user varchar(20) not null,
pass varbinary(500) not null
)
go
create function FU_ENCRYPT_PASS
(
@key varchar(50)
)
RETURNS VarBinary(500)
AS
BEGIN
DECLARE @pass AS VarBinary(500)
SET @pass = ENCRYPTBYPASSPHRASE('key', @key)
--encrypt the key to encrypt the field.
RETURN @pass
END
create function FU_DESENCRIPTA_PASS
(
@clave VARBINARY(500)
)
RETURNS VARCHAR(50)
AS
BEGIN
DECLARE @pass AS VARCHAR(50)
SET @pass = DECRYPTBYPASSPHRASE('key', @clave)
RETURN @pass
END
insert into user values(1,'user 1', dbo.ENCRYPT_PASS('1234'))
select * from user
go
select id_usuario, usuario, dbo.FU_DESENCRIPTA_PASS(pass) from usuario

You might also like