T-SQL????????????????????
???????????? ???????[ 2013/1/17 10:03:03 ] ????????
???????′????????SQLServer2008?????????????????
?????????????????????м??????????????????????????????
?????????Щ?????????????????????????????????????洢????????а????????????????????????????ó???????????ɡ????????????????????????
??????2005????????????????????????????????????????????£?
????1??????CONVERT?????????
????????ú???????????????????VARBINARY?????÷????????????????????????????????????????????????????????????á?
????2?????????????
????????EncryptByKey???????????????DecryptByKey???????н??????????????????????????????????????????????????
????3?????÷????????
????????EncryptByAsymKey???????????????DecryptByAsymKey???????н??????????????????????????????????????ж?
????4??????????????
????????EncryptByCert???м????DecryptByCert???????н???????????????????
????5????????????????
????????EncryptBypassPhrase???м???????DecryptByPassPhrase??????????????????????????????????????У??????????????????????????????????????
??????????
????1??Convert?????
a) USE tempdb
b) GO
c) CREATE TABLE test
d) (
e) userID INT IDENTITY(1?? 1) ??
f) userName VARCHAR(10) ??
g) userSalary FLOAT ??
h) cyberalary NVARCHAR(MAX)
i) ) ;
j)
k) INSERT INTO TEST
l) ( userName?? userSalary )
m) VALUES ( 'taici'?? 1234 )??
n) ( 'hailong'?? 3214 )??
o) ( 'meiyuan'?? 1111 )
p) --ALTER TABLE test
q) --ADD userNewSalary VARBINARY(512)
r) --?????????????????????varbinary???????????
s) SELECT * ??
t) CONVERT(VARBINARY(512)?? userSalary)
u) FROM test
v) --???????????int??????????б????
w) SELECT * ??
x) CONVERT(INT?? userSalary)
y) FROM test
????2??????????
a) --??????????
b) USE AdventureWorks
c) GO
d) CREATE SYMMETRIC KEY SymKey123
e) WITH ALGORITHM=TRIPLE_DES ENCRYPTION BYPASSWORD='P@ssw0rd'
f) GO
g) --???????:??????????????OPEN SYMMETRIC KEY ????????????????????????????????null??????????????Key_GUID?????????
h) --????????
i) OPEN SYMMETRIC KEY SymKey123 DECRYPTION BYPASSWORD='P@ssw0rd'
j) --???????????
k) SELECT * ??ENCRYPTBYKEY(KEY_GUID('SymKey123')??CONVERT(VARCHAR(max)??AddressLine1))
l) FROM Person.Address
m)
n) --??????????????datalength()????
o) SELECT DATALENGTH(ENCRYPTBYKEY(KEY_GUID('SymKey123')??CONVERT(VARCHAR(MAX )??AddressLine1)))
p) FROM Person.Address
q) GO
r) --????????????μ?????????????
s) UPDATE Person.Address
t) SET AddressLine2=ENCRYPTBYKEY(KEY_GUID('SymKey123')??CONVERT(VARCHAR(max)??AddressLine1))
u) --????:?????????????OPEN SYMMETRIC KEY ???????????DECRYPTBYKEY ??CONVERT????
v) OPEN SYMMETRIC KEY SymKey123 DECRYPTION BYPASSWORD='P@ssw0rd'
w)
x) SELECT AddressID??CONVERT(VARCHAR(MAX ) ??CONVERT (VARCHAR(MAX )??DECRYPTBYKEY(AddressLine2)))
y) FROM Person.Address
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11