Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Microsoft SQL Server 2008 R2 Unleashed- P41:SQL Server 2005 provided a number of significant new features and enhancements over what was available in SQL Server 2000. This is not too surprising considering there was a five-year gap between these major releases.Microsoft SQL Server 2008 is not as much of a quantum leap forward from SQL Server 2005 | 344 CHAPTER 12 Data Encryption Encrypting Columns Using a Passphrase As our first example let s keep things simple and look at how to encrypt a column using a passphrase. To do so let s look at the Sales.CreditCard table which currently stores card numbers in cleartext select top 5 from Sales.CreditCard go CreditCardID CardType CardNumber ExpMonth ExpYear ModifiedDate 1 SuperiorCard 333326646953 11 2006 2007 08 30 2 Distinguish 55552127249722 8 2005 2008 01 06 3 ColonialVoice 77778344838353 7 2005 2008 02 15 4 ColonialVoice 77774915718248 7 2006 2007 06 21 5 Vista 11114404600042 4 2005 2007 03 05 Credit card numbers really should not be stored in their cleartext form in the database so to fix this first create a copy of the Sales.CreditCard table and define the CardNumber_encrypt column as a varbinary 256 so you can store the encrypted credit card numbers in the column encrypted columns in SQL Server 2008 can be stored only as varbinary values USE AdventureWorks2008R2 GO select CreditCardID CardType CardNumber_encrypt CONVERT varbinary 256 CardNumber ExpMonth ExpYear ModifiedDate into Sales.CreditCard_encrypt from Sales.CreditCard where 1 2 Now you can populate the CreditCard_encrypt table with rows from the original CreditCard table using the EncryptByPassPhrase function to encrypt the credit card numbers as the rows are copied over declare @passphrase varchar 128 set @passphrase unencrypted credit card numbers are bad um-kay1 insert Sales.CreditCard_encrypt CardType CardNumber_encrypt ExpMonth ExpYear Download from www.wowebook.com Column-Level Encryption 345 ModifiedDate select top 5 CardType CardNumber_encrypt EncryptByPassPhrase @passphrase CardNumber ExpMonth ExpYear ModifiedDate from Sales.CreditCard Now try a query against the CreditCard_encrypt table without decrypting the data and see what it returns note for display purposes the values in the CardNumber_encrypt column have been truncated 12 select from Sales.CreditCard_encrypt go CreditCardID CardType .