-1

In ColdFusion 9 there is a GenerateSecretKey function. Can we generate the desired length key using GenerateSecretKey? I need to generate a 32 char secret key for my application.

Miguel-F
  • 13,450
  • 6
  • 38
  • 63
chandra
  • 1
  • 2

2 Answers2

2

GenerateSecretKey generates a key on the basis of algorithm, you can specify the keysize in bit that can increase the length of key generated.to generate 32 char key you can use CreateUuid.

Keshav jha
  • 1,356
  • 8
  • 22
0

If you just need a random string 32 characters long you can use createUUID(), however:

Returns

A ColdFusion format UUID, in the format xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx, where x is a hexadecimal digit (0-9 or A-F). (The character groups are 8-4-4-16.)

Including the dashes, that's 35 characters but

replace(createUUID(),"-","", "all")
left(createUUID(),"32")
right(createUUID(),"32")

will give you a string 32 characters long that may work for you.

genericHCU
  • 4,394
  • 2
  • 22
  • 34
  • I have to use this key for secrity purpose as api key for calling web service, createUUID will give unique for all course of time – chandra Mar 20 '13 at 11:46
  • The ColdFusion UUID generation algorithm uses the unique time-of-day value, the IEEE 802 Host ID, and a cryptographically strong random number generator to generate UUIDs that conform to the principles laid out in the draft IEEE RFC "UUIDs and GUIDs." – genericHCU Mar 20 '13 at 11:48