Encrypt

Description

Encrypts a string. Encrypt uses a symmetric key-based algorithm in which the same key is used to encrypt and decrypt a string. The security of the encrypted string depends on maintaining the secrecy of the key. Encrypt uses an XOR-based algorithm that uses a pseudo-random 32-bit key based on a seed passed by the user as a parameter to the function. The resultant data is UUencoded and may be as much as three times the original size.

Category

String functions

Syntax


Encrypt(string, seed) 

See also

Decrypt

Parameters

Parameter
Description
string
String to encrypt
seed
String that specifies the seed used to generate the 32-bit key needed to encrypt the string

Example

<!--- This example shows the use of Encrypt and Decrypt --->

<html>

<head>

<title>Encrypt Example</title>

</head>



<body bgcolor = silver>

<H3>Encrypt Example</H3>



<P>This function allows for the encryption and decryption of a 

string. Try it out by entering your own string and a key of your 

own choosing and seeing the results.

<cfif IsDefined("FORM.myString")>

  <cfset string = FORM.myString>

  <cfset key = FORM.myKey>

  <cfset encrypted = encrypt(string, key)>

  <cfset decrypted = decrypt(encrypted, key)>

  <cfoutput>

   <H4><B>The string:</B></H4> #string# <BR>

   <H4><B>The key:</B></H4> #key#<BR>

   <H4><B>Encrypted:</B></H4> #encrypted#<BR>

   <H4><B>Decrypted:</B></H4> #decrypted#<BR>

  </cfoutput>

</cfif>

<form action = "encrypt.cfm" method = "post">

<P>Input your key:

<P><input type = "Text" name = "myKey" value = "foobar">

<P>Input your string to be encrypted:

<P><textArea name = "myString" cols = "40" rows = "5" WRAP = "VIRTUAL">

This string will be encrypted (try typing some more)

</textArea>

<input type = "Submit" value = "Encrypt my String">

</FORM>

</body>

</html>    



Banner.Novgorod.Ru