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 EncryptionHow One-Way Encryption WorksAs noted in the introduction, disclosure of the secret value, encrypted usingone-way encryption, is achieved through comparing the stored hash value witha second hash value, or search value. This search value is generated using thesame algorithm that created the stored hash value. When a positive matchis verified between the stored hash value and the search value, the storedhash value's original plain text value is indirectly revealed, as illustrated inFigure 7-1.Figure 7-1: Searching for a plain text value among protected data.In SQL Server, one-way encryption is accomplished through use of theHashbytes method. This method uses a selected algorithm to generate a hash.Unlike the cell-level encryption methods, which produce a unique hash eachtime a plain text value is encrypted, the Hashbytes method will return theidentical hash for a given text regardless to how many times the method isexecuted.For example, when the plain text value of "1234567890" is hashed with theSHA1 algorithm, it will reliably return a hash value of0x01B307ACBA4F54F55AAFC33BB06BBBF6CA803E9A each time Hashbytes isexecuted for that plain text value. Below is the syntax for this method:HashBytes([Algorithm], [Plain Text])This method's arguments are:• Algorithm: The algorithm used to create the cipher text. The optionsfor this argument are: MD2, MD4, MD5, SHA and SHA1. For specificdetails regarding these options see Chapter 4.• Plain Text: The plain text that is being converted into cipher text.The Hashbytes method will be used extensively in our implementationexample of one-way encryption for our HomeLending database.148

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

Saved successfully!

Ooh no, something went wrong!