What are the challenges you face when working across database platforms? Take the survey

Generate data in table with Encryption

I would like generate data in a database where some columns are with encryption.
So I have VARBINARY (500) where address, phone and other data are encrypter.
I would like create fake data with consistent.
For encrypt I do :
        [Phonen1_E] = EncryptByKey (Key_GUID('SymKey'),@Phonen1, 1, CONVERT(VARBINARY, EntityId)),

How I can do that with SQL Data Generator V4?
Who I can put data with my encryption?
Best Regards



  • Options
    Unfortunately, I don't think SQL Data Generator can encrypt your data for you.  As a workaround, you could create a table with the equivalent unencrypted columns and then select the data across with a call to your encryption routine.
    Software Developer
    Redgate Software
  • Options
    I know this is old, but posting my answer if anyone is searching this forum.

    I was able to complete this using a custom SQL Command. This example generates a random date somewhere from 01/01/1951 to 01/01/2001, then encrypts it and returns the bit value. This only returns one value so I set the flag to loop for all rows. 

    DECLARE @dateenc varbinary(128)
    SET @dateenc=  EncryptByKey(Key_GUID('SymKey'),CONVERT(nvarchar(10),DATEADD(DAY, ABS(CHECKSUM(NEWID()) % 18615), '1950-01-01')))

    SELECT @dateencAS dateenc 
Sign In or Register to comment.