Skip to main content
Inspiring
October 17, 2012
Question

Where to set key to be used with Encrypt function

  • October 17, 2012
  • 1 reply
  • 639 views

I'm about to use CF Encrypt function because I need to pass a var via url.

In order to use Encrypt () I need to create a KEY but I don't want to keep setting this key on the page where I need to use Encrypt()

Can anyone point me to the right direction on where is the best place to set this key so I can just refer to this key anytime I need it?

Can I do <cfset session.MyEncyprteKey = ....>? and everytime I need this key I just use #session.MyEncryptedKey# ?

I'm using CF8 and Application.cfc

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
October 18, 2012

I would have thought you would set the key per application, rather than per user session. For example, in onApplicationStart:

<cfset application.key = generateSecretKey("Blowfish")>

You would then refer each time to application.key.