programming4us
programming4us
DATABASE

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

- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire

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
  •  
    Top 10
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
    - Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
    - Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
    - Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
    - Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
    - Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
    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)
    programming4us programming4us
    Celebrity Style, Fashion Trends, Beauty and Makeup Tips.
    programming4us
     
     
    programming4us