Decrypt Connection String in DBUtils

Posts   
 
    
Posts: 31
Joined: 17-Aug-2005
# Posted on: 27-May-2008 13:01:30   

Hi,

I want to know if it is possible to encrypt my "Main.Connectionstring" in the Web/App.Config and then decrypt it in the DBUtils code. When I generate the new classes it overwrites my decryption.

We have a client that insist we have encrypted details in the Web/App.Config file.

Any suggestions?

Best regards,

Philip

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 27-May-2008 19:40:50   

Make all your modifications to DBUtils code in a partial class to avoid loosing your changes when generating new classes.

Posts: 31
Joined: 17-Aug-2005
# Posted on: 28-May-2008 11:08:49   

Goose,

I still need to make code changes to the DBUtils to be backwards compatible.

Any samples?

Regards,

Philip

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
Posts: 31
Joined: 17-Aug-2005
# Posted on: 02-Jun-2008 09:39:36   

Hi Walaa,

Thanks for the links but I need to know how to change the DBUtils class to accommodate my changes and not to override when I re-generate the code.

Unfortunately I'm on a very tight deadline and cannot research myself.

Thanks,

Philip

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Jun-2008 10:02:12   

The fastest easiest solution is to use an external class/method to handle the decryption outside the dbUtils, and set the DbUtils.ActualConnectionString with the decrypted value.

Otherwise if you want to execute the decryption from within the DBUtils class, then you may modify the dbUtils.template, found at <LLBLGen installation folder>\Templates\SqlServerSpecific\Net2.x\C# If you are using SQLServer for example.

You should modify the CreateConnection method. So that whenever you re-generate the code the decryption code get generated too.

Also it might be better if you copy the dbUtils.template into a new file with another name and add your modifications there then use it in the Designer instead of the original dbUtils.template, this should keep the original template intact in case you want to revert back to it, or use it in another project.