Viewing Category: Lucee  [clear category selection]

Lucee Database Passwords

Often times I need to dynamically create a datasource upon the deploy of an application within Lucee. It's easy to setup the datasource in Application.cfc, as documented. However, you'll need to know the encrypted form of the database user's password. That can be a challenge to generate within an unattended script. But with CommandBox, our fucking troubles are over, Dude.

Open up the CommandBox REPL and execute the following to encrypt your database user's high-quality password using Lucee's secret key (sdfsdfs):

CFSCRIPT-REPL: be = createObject("java", "lucee.runtime.crypt.BlowfishEasy").init("sdfsdfs"); CFSCRIPT-REPL: be.encryptString("Password1!");

The sequence of hex characters can be dropped into your Application.cfc. Like so:

component { = "FooBar";   this.datasource = {     class: "",     connectionString: "jdbc:sqlserver://;databasename=fooBar",     username: "sa",     password: "encrypted:4b613047d2594b9b905be02f11575afb5e88f425739cc9e2a1f3f167530b03c9"   }; }

If you ever forget your database password, you can recover it simply:

CFSCRIPT-REPL: be = createObject("java", "lucee.runtime.crypt.BlowfishEasy").init("sdfsdfs"); CFSCRIPT-REPL: be.decryptString("4b613047d2594b9b905be02f11575afb5e88f425739cc9e2a1f3f167530b03c9");