Skip to main content

Posts

Showing posts with the label security

ColdFusion - How to determine whether a user is logged in

IsUserLoggedIn() - determine whether a user is logged in IsUserLoggedIn.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>IsUserLoggedIn function example: how to determine whether a user is logged in</title> </head> <body> <h2 style="color:Crimson">IsUserLoggedIn Function Example</h2> <cfoutput> <cfif IsUserLoggedIn()> User is logged in.<br /> <b>User Name:</b> #GetAuthUser()# <cfelse> User is not logged in </cfif> </cfoutput> <cflogout> <br /><br /> -----After logged out--- <br /><br /> <cfoutput> <cfif IsUserLoggedIn()> User is logged in.<br /> <b>User Name:</b> #GetAuthUser()# <cfelse> User is not logged in <...

ColdFusion - Determine whether an authenticated user belongs to the specified role

IsUserInRole() - determine whether an authenticated user belongs to the specified role IsUserInRole.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>IsUserInRole function example: how to determine whether an authenticated user belongs to the specified role</title> </head> <body> <h2 style="color:Crimson">IsUserInRole Function Example</h2> <cfset UserRoles=GetUserRoles()> <cfoutput> <cfif IsUserInRole("admin")> <b>Current user is in role</b>: admin <cfelseif IsUserInRole("superadmin")> <b>Current user is in role</b>: superadmin <cfelse> <b>Current user is not in roles: admin, superadmin</b> </cfif> </cfoutput> </body> </html> More...

ColdFusion Hash() function with MD5 algorithm

Hash() - MD5 algorithm HashMD5.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Hash function example: how to use Hash function with MD5 algorithm</title> </head> <body> <h2 style="color:Crimson">Hash Function Example: MD5</h2> <cfset TestString="This is a string"> <cfset HashTestString=Hash(TestString,"MD5")> <cfoutput> <b>TestString:</b> #TestString# <br /> <b>Hash TestString[algorithm MD5]:</b> #HashTestString# </cfoutput> </body> </html> More ColdFusion example IIF()

How to generate a secret key with algorithm AES in ColdFusion

GenerateSecretKey() - generate a secret key with algorithm AES GenerateSecretKeyAES.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>GenerateSecretKey function example: how to generate a secret key with algorithm AES</title> </head> <body> <h2 style="color:Crimson">GenerateSecretKey Function Example: AES</h2> <cfset SecretKey=GenerateSecretKey("AES")> <cfoutput> <b>SecretKey[algorith AES]:</b> #SecretKey# </cfoutput> </body> </html> More ColdFusion examples CreateObject() - create a coldfusion object (type component) GetComponentMetaData() - get metadata for a cfc (coldfusion component) DE() - escape any double-quotation marks in the parameter and wraps the result in double-quotation marks

How to encrypt a string using a specific algorithm and encoding method in ColdFusion

Encrypt() - encrypt a string using a specific algorithm and encoding method Encrypt.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Encrypt function example: how to encrypt a string using a specific algorithm and encoding method</title> </head> <body> <h2 style="color:Crimson">Encrypt Function Example</h2> <cfset TestString="This is a string"> <cfset SecretKey=GenerateSecretKey("DESEDE")> <cfset EncryptString=Encrypt(TestString,SecretKey)> <cfoutput> <b>TestString:</b> #TestString# <br /> <b>TestString[after encrypt]:</b> #EncryptString# <br /> <b>TestString[after decrypt]:</b> #Decrypt(EncryptString,SecretKey)# </cfoutput> </body> </html> More ColdFusion examples Cr...

How to decrypt a string that is encrypted using a standard encryption technique in ColdFusion

Decrypt() - decrypt a string that is encrypted using a standard encryption technique Decrypt.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Decrypt function example: how to decrypt a string that is encrypted using a standard encryption technique</title> </head> <body> <h2 style="color:Crimson">Decrypt Function Example</h2> <cfset TestString="This is a string for test Decrypt function"> <cfset SecretKey=GenerateSecretKey("BLOWFISH")> <cfset EncryptString=Encrypt(TestString,SecretKey)> <cfoutput> <b>TestString:</b> #TestString# <br /> <b>TestString[after encrypt]:</b> #EncryptString# <br /> <b>TestString[after decrypt]:</b> #Decrypt(EncryptString,SecretKey)# </cfoutput> </body> ...