| | |
Decrypting an encrupted credit card number
Please support our ColdFusion advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 331
Reputation:
Solved Threads: 27
I'm tring to display an encrypted number store in sql database I have a key store in my application.cfm. and they number in my database is encrypted. My display code looks like this
ColdFusion Syntax (Toggle Plain Text)
<cfloop query="Get_Orders"> <cfoutput> <tr> <td><div class="content_black">#Get_Orders.Credit_Card_Type# </div></td> <cfset key = #application.key#> <cfset Cardnum = '#Get_Orders.Credit_Card_Number#'> <cfset CardDec = decrypt(Cardnum, key)> <td><div class="content_black">#CardDec# </div></td> <td><div class="content_black">#Get_Orders.Credit_Card_Month# </div></td> <td><div class="content_black">#Get_Orders.Credit_Card_Year# </div></td> <td><div class="content_black">#Get_Orders.Credit_Card_Name# </div></td> <td><div class="content_black">#Get_Orders.Comments# </div></td> <td><textarea name="HL_Comments_#Get_Orders.Order_Estimate_ID#" cols="20" rows="5">#Get_Orders.HL_Comments#</textarea></td> <td align="center"><input type="Checkbox" name="Contacted_#Get_Orders.Order_Estimate_ID#" value="1"<cfif Get_Orders.Contacted IS 1> checked</cfif>></td> <td><div class="content_black">#Get_Orders.customerNumber#</div></td> <td><div class="content_black">#Get_Orders.billing_phone#</div></td> <td><div class="content_black">#Get_Orders.Billing_Email# </div></td> <td><div class="content_black">#DollarFormat(Get_Orders.invoiceAmt)#</div></td> <td align="center"><div class="content_black"><input type="Checkbox" name="Processed_#Get_Orders.Order_Estimate_ID#" value="1"<cfif Get_Orders.invoiceProcessed IS 1> checked</cfif>></div></td> </tr> </cfoutput> </cfloop>
•
•
Join Date: Sep 2008
Posts: 331
Reputation:
Solved Threads: 27
Well it turns out when every my encrypted string has a " in it when it gets store to my sql database it stops at the " . Is there any way to create the encryption string with no characters?
•
•
Join Date: Dec 2008
Posts: 45
Reputation:
Solved Threads: 6
Is that a double quote or two single quotes? What syntax are you using to insert the encrypted string into the database?
Side notes:
Since I don't work with cc's I am curious... is it a good idea to actually display the full credit card number on the web page?
This has nothing to do with the problem, but there is no need for those # signs. Just use:
<cfset Cardnum = Get_Orders.Credit_Card_Number>
<cfset CardDec = decrypt(Cardnum, application.key)>
Side notes:
Since I don't work with cc's I am curious... is it a good idea to actually display the full credit card number on the web page?
•
•
•
•
<cfset key = #application.key#>
<cfset Cardnum = '#Get_Orders.Credit_Card_Number#'>
<cfset CardDec = decrypt(Cardnum, key)>
<cfset Cardnum = Get_Orders.Credit_Card_Number>
<cfset CardDec = decrypt(Cardnum, application.key)>
•
•
Join Date: Sep 2008
Posts: 331
Reputation:
Solved Threads: 27
Here is the syntex
here is the encrypted string
0U5K" Z7*%U;#T,(/B?GX)0
it will only insert OU5K into the data base
Here is another
0U5[" ZG&$E/&T\8#BOC[(P
my sql table has
OU5[
I also tried
<cfset key = #application.key#>
<cfset Cardnum = '#Get_Orders.Credit_Card_Number#'>
<cfset CardDec = decrypt(Cardnum, key)>
and I still get " in my output
After I get this working thats my next task to trim the credit card being displayed on the page to the last 4 numbers
ColdFusion Syntax (Toggle Plain Text)
<cfset string = FORM.numCredit> <cfset key = ToBase64(BinaryDecode(#application.key#, "HEX"))> <cfset encrypted = encrypt(string, key)>
here is the encrypted string
0U5K" Z7*%U;#T,(/B?GX)0
it will only insert OU5K into the data base
Here is another
0U5[" ZG&$E/&T\8#BOC[(P
my sql table has
OU5[
I also tried
<cfset key = #application.key#>
<cfset Cardnum = '#Get_Orders.Credit_Card_Number#'>
<cfset CardDec = decrypt(Cardnum, key)>
and I still get " in my output
After I get this working thats my next task to trim the credit card being displayed on the page to the last 4 numbers
Last edited by freshfitz; Dec 16th, 2008 at 7:12 am.
•
•
Join Date: Dec 2008
Posts: 45
Reputation:
Solved Threads: 6
•
•
•
•
Here is the syntex
ColdFusion Syntax (Toggle Plain Text)
<cfset string = FORM.numCredit> <cfset key = ToBase64(BinaryDecode(#application.key#, "HEX"))> <cfset encrypted = encrypt(string, key)>
ColdFusion Syntax (Toggle Plain Text)
INSERT INTO YourTable ( EncryptedValue ) VALUES ( <cfqueryparam value="#encrypted#" cfsqltype="( sql type for the column )"> )
•
•
Join Date: Sep 2008
Posts: 331
Reputation:
Solved Threads: 27
Here is my insert string
ColdFusion Syntax (Toggle Plain Text)
<form action="payments_autopay.cfm" method="post"> <input type="Hidden" name="action" value="confirm"> <input type="Hidden" name="selCreditCard" value="#form.selCreditCard#"> <input type="hidden" name="numCredit" value="#encrypted#"> <input type="hidden" name="selExpMonth" value="#form.selExpMonth#"> <input type="Hidden" name="selExpYear" value="#form.selExpYear#"> <input type="Hidden" name="vcCreditName" value="#form.vcCreditName#"> <input type="Hidden" name="customerNumber" value="#customerNumber#"> <!--- <input type="Hidden" name="orderID" value="#findOrder.Order_Estimate_ID#"> ---> <input type="Hidden" name="comments" value="#form.vccomments#"> <input type="Hidden" name="email" value="#form.email#"> <input type="hidden" name="bill_fname" value="#form.bill_vcfname#"> <input type="hidden" name="bill_lname" value="#form.bill_vclname#"> <input type="hidden" name="Bill_vcAddress1" value="#form.Bill_vcAddress1#"> <input type="hidden" name="bill_vcCity" value="#form.bill_vcCity#"> <input type="hidden" name="bill_vcST" value="#form.bill_vcST#"> <input type="hidden" name="bill_numZip" value="#form.bill_numZip#"> <input type="hidden" name="bill_phone" value="#form.bill_numPhone#"> <tr> <td colspan="2"> </td> </tr> <tr> <td> <a href="##" onclick="document.forms[0].submit()"><img src="images/button_confirmInfo.gif" width="132" height="18" alt="Confirm Information" title="Confirm Information" border="0"></a><br><br> <!-- <input type="Submit" name="submitBtn" value="Confirm"> --> </td> </tr> </form> </table> </cfoutput> <!--- </CFIF> ---> <CFELSEIF isDefined("form.action") and form.action EQ "confirm"> <cfquery name="findOrder" datasource="#request.dsn#"> INSERT INTO HL_OrderEstimates(credit_card_type,credit_card_number,credit_card_month,credit_card_year,credit_card_name,invoiceProcessed,autopay,autopayDate, billing_fname,billing_lname,billing_address1, billing_city,billing_state,billing_zip, billing_phone, customerNumber) VALUES('#form.selCreditCard#','#form.numCredit#','#form.selExpMonth#','#form.selExpYear#','#form.vcCreditName#', 0, 1,getDate(),'#form.bill_fname#','#form.bill_lname#','#form.Bill_vcAddress1#','#form.bill_vcCity#', '#form.bill_vcST#', '#form.bill_numZip#', '#form.bill_phone#', '#customerNumber#') </cfquery>
•
•
Join Date: Nov 2008
Posts: 20
Reputation:
Solved Threads: 0
look my friend i had the same problem and i solved using this kind of encryption
hope it help
Thanks
coldfusion Syntax (Toggle Plain Text)
<cfparam name="Request.PasswordKey" default="keyyyyyyyyyyyyyy"> <cfset Encrypted = Encrypt(form.number, Request.PasswordKey)> <cfquery datasource="db"> Insert Into table (field1, field2, ,field3) Values (<cfqueryparam value="#form.na#">, <cfqueryparam value="#Encrypted#">) </cfquery> and when you want to decrypt the date use <cfset decrypt = decrypt(fildes, Request.PasswordKey)>
Thanks
Last edited by peter_budo; Dec 18th, 2008 at 3:19 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: Dec 2008
Posts: 45
Reputation:
Solved Threads: 6
•
•
•
•
look my friend i had the same problem and i solved using this kind of encryption
Though, I agree with Salem about security. If you are storing credit card information security and encryption should be very tight. If you are not well versed in it or don't have the experience and resources, there are reputable companies that do. Consider the liability if security is poor ..
![]() |
Other Threads in the ColdFusion Forum
- Previous Thread: Please Help
- Next Thread: Authenticate cfmail with exchange
| Thread Tools | Search this Thread |






