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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

8 – ObfuscationNumeric variance is a process in which the numeric values that are storedwithin a development database can be changed, within a defined range, so asnot to reflect their actual values within the production database. By defining apercentage of variance, say within 10% of the original value, the values remainrealistic for development and testing purposes. The inclusion of a randomizerto the percentage that is applied to each row will prevent the disclosure of theactual value, through identification of its pattern.In the HomeLending database, we will create a user defined function calledNumeric_Variance that increases or decreases the value of the value passedto it by some defined percent of variance, also passed as a parameter to thefunction. For example, if we want the value to change within 10% of its currentvalue we would pass the value of 10 in the @ValPercent argument.A randomizer is added through the use of the vwRandom view that we createdearlier in this chapter. This will vary the percent variance on a per executionbasis. For example, the first execution may change the original value by 2%,while the second execution may change it by 6%.The script to create this Numeric_Variance function, which can bereferenced as needed in other views and stored procedures, is shown in Listing8-6.USE HomeLending;GO-- Create user defined functionCREATE FUNCTION Numeric_Variance(@OrigVal float,@VarPercent numeric(5,2))RETURNS floatWITH ENCRYPTIONASBEGIN-- Variable usedDECLARE @Rand int;-- Random position of character to useSELECT@Rand = Convert(int,((((0-@VarPercent)+1) -@VarPercent) * RandomValue + @VarPercent))FROMdbo.vwRandom;ENDRETURN @OrigVal + CONVERT(INT,((@OrigVal*@Rand)/100));180

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

Saved successfully!

Ooh no, something went wrong!