17.07.2015 Views

Download eBook (PDF) - Red Gate Software

Download eBook (PDF) - Red Gate Software

Download eBook (PDF) - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7 – One-Way EncryptionLater in this chapter we will take the code provided in Listing 7-6 and place itin a stored procedure, which will be used when the records are inserted andupdated.Verify the ImplementationTo verify that our hash values were successfully generated, we can executeSELECT statements that filter, based upon our newly generated columns, asshown in Listing 7-7.USE HomeLending;GODECLARE @Salt varchar(7)SET @Salt = dbo.GetHashSalt('L01');-- Returns search by full SSNSELECTIdentification_ValueFROMdbo.Borrower_IdentificationWHEREIdentification_Value_H =HASHBYTES('SHA1', @Salt + '555-20-7151');-- Returns search by last four digits of SSNSELECTIdentification_ValueFROMdbo.Borrower_IdentificationWHEREIdentification_Value_HT =HASHBYTES('SHA1', @Salt + '7151');GOListing 7-7: Testing the one-way encryption.The results of these queries, indicating successful implementation of one-wayencryption, would appear as follows:Identification_Value-------------------------------------------------------555-20-7151(1 row(s) affected)Identification_Value-------------------------------------------------------555-20-7151(1 row(s) affected)161

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!