To expand on this a little further, you could use the following code...

index.cfm
--------------------
<cffile action="READ"
        file="c:\key.txt"
        variable="mykey">
<img
src="picture.cfm?picture=#URLEncodedFormat(encrypt('C:\WINNT\Help\iis\htm\tu
torial\rock.jpg', mykey))#">

picture.cfm
--------------------
<cffile action="READ"
        file="c:\key.txt"
        variable="mykey">
<cfset image = #decrypt(picture, mykey)#>
<cfset imagetype = iif(listlast(picture, '.') EQ 'gif',  de('image/gif'),
de('image/jpeg'))>
<cfcontent file="#image#" type="#imagetype#">

key.txt
--------------------
anythingyoulikeasanencryptionkey

As you can see in this example the encryption key is stored in a file called
key.txt but could just as easily come from a database, either way you can
change it with ease.  You could even set up a scheduled task to randomise
the key on an hourly basis if you wanted (depending on just how secure you
want it).

The file name is also URLEncoded to avoid html characters from messing up
the string.

If you are running NT4 you probably have the image I used as an example on
your system, and it is not in the web servers path anywhere, yet will
display correctly.  You will also be able to see (by viewing source) that
the chance of anyone guessing a correct sequence is remote at best. Using
"anythingyoulikeasanencryptionkey" as the key the img tag becomes...

<img
src="picture.cfm?picture=G6%205OOB%29RHZN%5B5%3FOPH%5E%5C%26E%5BF%2AITD1P%2D
N2BZ%29%257A%2A%23N%28WP%3D8%3EW6%3AF%3B%0A">

and if that isn't secure enough for you, then nothing is!

The supplied code will work fine for .gif, .jpg and .jpeg images, but you
will have to modify it slightly if you use png or other formats.

Have fun.

--
James Smith
[EMAIL PROTECTED]


------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to