Encryption of strings in Cold Fusion

There are different ways strings can be encrypted in CFM. It depends upon the scenario how we need it. Some cases you need to encrypt the data but no need to decrypt it back. That means situation like store the encrypted password in database but you may not want to expose it to anyone. Here I�m going to show few examples how you can encrypt the CFM string.

Encrypt ()

Use this function to encrypt a string.


Code:
<cfset myString=�this is the data�>
<cfset myKey=�thisisthekey�>
<cfset myencryptedString=Encrypt (myString, myKey)>

<cfoutput>#myencryptedString# </cfoutput>



Decrypt ()

In case you need to get the encrypted data back to your original string. You can try this

Code:
<cfset myOriginalString=encrypt (myencryptedString, myKey)>

<cfoutput>#myOriginalString#</cfoutput>



HASH()

Use hash function if you don�t want to decrypt the value back. This is the safest method to store passwords in database. It converts a variable-length string to a fixed-length string that can act as a fingerprint or unique identifier for the original string. You can specify what algoritham should be used for this conversion.

Code:
<cfset myString=�this is the data�>
<cfset myHashedString=HASH (myString)>
<cfoutput>#myHashedString # </cfoutput>


There are various other conversion and security functions are available in cold fusion. You may take a look at the cold fusion documentation for more details.

Commentaires

Posts les plus consultés de ce blog

XAJAX with PHP – The future of web development

XAJAX with PHP – The future of web development

Database connection pooling in ADO.Net