Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 379
  • Last Modified:

How to encrypt/decrypt data?

Hi,

I have a webpage written in Coldfusion and would like user to submit info (Registration type). How can I enrypt the data when adding the record to Access and decrypt it when user needs to view it? My database is reside at someone's server and I do not want the Admin to view anything.

Other Questions:
1. Anyway to encrypt data already in Access?
2. Any other easier ways to do it, for lazy person like me? (Example: Just encrypt the whole database rather than do it for each data entry)
3. And lastly, where to encrypt the data? Part of my registration page is as below. Modify my code will be very helpful.

<tr><td>Company*</td>
<td><input name="name" size="30"></td></tr>

<tr><td>Login Name*</td>
<td><input class=textfield type=text name="loginname" size="30"></td></tr>

<tr><td>Address 1*</td>
<td><input name="address1" size="30"></td></tr>

<tr><td>Address 2</td>
<td><input name="address2" size="30"></td></tr>

Thanks.
0
buybuy
Asked:
buybuy
1 Solution
 
jimmy282Commented:
You can use the Inbuilt Coldfusion Functions.
Encrypt() and Decrypt()

Have a look at this 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>    



You encrypt it before you enter the record into database and decrypt it when you fetch from database.

Hope it helps.

Jimmy
0
 
anandkpCommented:
HI there,

Jimmy is perfectly right abt this -

but make sure u set ur key value to something like "buybuy_or_whatever_u_want"

& use the same key value while encrypting & decrypting ur values.

keep in mind that if at ne-point u change ur key value - u cannot decrypt teh earlier encrypted values, using the new key.

so the value of key - has to remain a constant - througout !!!

K'Rgds
Anand
0
 
buybuyAuthor Commented:
Thanks guys for your help. :)
0
 
misterginCommented:
I heard that the native encryption techniques were less than ideal, any news on their status in MX?

I've had several friends use other custom methods instead because of this...
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now