Avatar of billg7
billg7Flag for United States of America

asked on 

Decrypting A String of Numbers Using ColdFusion decrypt tag

Hi Experts,

I'm trying to write a script that will take a 20 digit string of base10 numbers (e.g., 1234-5678-9012-3456-7890) that is encrypted from an 18 digit base10 number (e.g., 123456789012345678) and decrypt back to the original 18 digit number. The 18digit number was encoded with 3DES (DESEDE). The three keys are in hex (e.g., key1=4e4e4e4e4e4e4e4e, key2=4e4e4e4e4e4e4e4e, key3=4e4e4e4e4e4e4e4e - yes I'm aware; this set of keys makes it very insecure and equivalent to single DES, it's just for example). My thinking was that the following code would work, but I was wrong. I'm guessing I have a simple syntax problem or it's passing a bad format and the hex number is not being recognized as an actual hex number, so it may be just setting the variable correctly as a hex that will fixit... Please help and thank you in advance!!


<cfset MyString="12345678901234567890"> *Note: the 20 dig encrypted base 10 number
<cfset MyKey="4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e4e">
<cfset decrypted_text= decrypt(MyString, MyKey, "DESEDE","HEX")>
 
<CFOUTPUT>#decrypted_text#

Open in new window

Web ServersColdFusion Language

Avatar of undefined
Last Comment
billg7
Avatar of shariff_pasha
shariff_pasha

<cfset myAlgorithm = "CFMX_COMPAT">
<cfset theKey= "CFMX_COMPAT">
<cfset  myEncoding = "Base64" >

<cfset eC=#Encryptform.name,theKey,myAlgorithm,myEncoding)#>

and the variable eC is encrypted
in the same way u can decrypt
<cfset eC2= #Decrypt(form.name,theKey,myAlgorithm,myEncoding)#>

try this hope it helps u..

http://shariffdotnet.blogspot.com
Avatar of shariff_pasha
shariff_pasha

and... u have to put ## signs

<cfset decrypted_text=# decrypt(MyString, MyKey, "DESEDE","HEX")#>
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of billg7
billg7
Flag of United States of America image

ASKER

I agree, you don't need hash marks ('#') to declare the var. The inputbasen function didn't work either, it gave me a "must input a valid base 16 number" error. Thoughts?
Avatar of billg7
billg7
Flag of United States of America image

ASKER

Oh and no, the encoding formula I don't have...
Web Servers
Web Servers

A web server refers to the software that helps to deliver web content that can be accessed either through the Internet or through an intranet. The primary function of a web server is to store, process and deliver web pages to clients. The communication between client and server takes place using the Hypertext Transfer Protocol (HTTP). The most common use of web servers is to host websites, but there are other uses such as gaming, data storage, running enterprise applications, handling email, FTP, etc.

33K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo