DATABASE

SQL Server : Implementing One-Way Encryption (part 1) - Populate the Hash Columns, Verify the Implementation, Drop the Unencrypted Column

5/31/2014 3:30:22 AM

Populate the Hash Columns

The next step will be to populate our new Identification_Value_H and Identification_Value_HT columns with the hash values of the Identification_Value column.

Listing 4 shows the script to do this. It uses the GetHashSalt user defined function to salt the values in the Identification_Value column and then updates the data in our the newly-created hash columns in our Borrower_Identification table so that they are salted and hashed, in the case of the Identification_Value_H column, and salted, truncated and hashed, in the case of the Identification_Value_HT column.

Listing 4. Salting and hashing the Identification_Value column.

Verify the Implementation

To verify that our hash values were successfully generated, we can execute SELECT statements that filter, based upon our newly generated columns, as shown in Listing 5.

Listing 5. Testing the one-way encryption.

The results of these queries, indicating successful implementation of one-way encryption, would appear as follows:

Identification_Value
-------------------------------------------------------
555-20-7151
(1 row(s) affected)
Identification_Value
-------------------------------------------------------
555-20-7151
(1 row(s) affected)

Drop the Unencrypted Column

Having successfully encrypted the contents of our Identification_Value column, captured it into the Identification_Value_H and Identification_Value_HT columns, and verified that they are working correctly; we can remove the Identification_Value column that contains the plain text values of our sensitive data.

This is accomplished through the use of the ALTERTABLE method and the DROP COLUMN argument, as shown in Listing 6.

Listing 6. Dropping the plain-text column.

Please note that the plain text values contained in this column will be permanently lost with its removal. This is definitely an action in which we will want to take pause. Perform the DROPCOLUMN command only if you are certain that you will no longer need to reference its contents. At the beginning of this process we performed a database backup which will provide us a means of recovery if needed. If the plain text values are archived to another location it too will need to be protected.

Other  
  •  Sql Server 2012 : Hierarchical Data and the Relational Database - Hierarchical Table Indexing Strategies
  •  Sql Server 2012 : Hierarchical Data and the Relational Database - Populating the Hierarchy (part 3) - The GetAncestor Method
  •  Sql Server 2012 : Hierarchical Data and the Relational Database - Populating the Hierarchy (part 2) - The ToString Method
  •  Sql Server 2012 : Hierarchical Data and the Relational Database - Populating the Hierarchy (part 1)
  •  Sql Server 2012 : Hierarchical Data and the Relational Database - The hierarchyid Data Type, Creating a Hierarchical Table
  •  Personal Cloud WD My Cloud EX2 Review
  •  Synology DS213j Your Own Cloud Entertainment Starts Here
  •  ADATA Premier Pro SP920 256GB
  •  Netgear ReadyNAS 314 Enterprise Network Storage
  •  Budget Portable Hard Drivers Review
  •  
    Video
    Top 10
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    The latest Audi TT : New angles for TT
    Era of million-dollar luxury cars
    Game Review : Hearthstone - Blackrock Mountain
    Game Review : Battlefield Hardline
    Google Chromecast
    Keyboards for Apple iPad Air 2 (part 3) - Logitech Ultrathin Keyboard Cover for iPad Air 2
    Keyboards for Apple iPad Air 2 (part 2) - Zagg Slim Book for iPad Air 2
    Keyboards for Apple iPad Air 2 (part 1) - Belkin Qode Ultimate Pro Keyboard Case for iPad Air 2
    Michael Kors Designs Stylish Tech Products for Women
    REVIEW
    - First look: Apple Watch

    - 3 Tips for Maintaining Your Cell Phone Battery (part 1)

    - 3 Tips for Maintaining Your Cell Phone Battery (part 2)
    Popular Tags
    Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Exchange Server Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe Photoshop CorelDRAW X5 CorelDraw 10 windows Phone 7 windows Phone 8 Iphone