• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Encrypt/Decrypt DES & other languages

New Here ,
Mar 01, 2007 Mar 01, 2007

Copy link to clipboard

Copied

I'm trying to encrypt a basic string on a CFMX v7 app using the Encrypt function, DES, and Base64 encoded text.
Then I need to pass that to an ASP.Net page where I will decode it.

It seems that the only way to create a key for the Encrypt function is by using generateSecretKey("DES"). But if I have to use the same key on the receiving end how do I force CFMX to use a key I specify?

Is what I'm trying to accomplish even possible? Is there a better way to do this?

TIA
J
TOPICS
Advanced techniques

Views

431

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 01, 2007 Mar 01, 2007

Copy link to clipboard

Copied

Do you need to use a pre-specified key, or can you use the one generated by the generateSecretKey() call? If you have an existing key you need to use, have you tried passing it into the encrypt() function using toBase64() to convert it to base 64?

i.e.:
#encrypt("some text to encrypt", toBase64(myDesKey), "DES")#

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2007 Mar 02, 2007

Copy link to clipboard

Copied

Michael, Thanks you for your input.

I do need to use a pre-specified key. I tried your suggestion and converted it to Base64 at which point it complained about the key length being invalid for this encryption. It then suggested that I use the GenerateSecretKey function.

My code:
encrypted=encrypt("This is a test 100", toBase64("1A1AA5B64D51677A"),"DES");


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 02, 2007 Mar 02, 2007

Copy link to clipboard

Copied

Yeah, I was getting that error as well when I tried it too, but I thought it might just be because I wasn't using a correct DES key.

What happens if you generate a key using coldfusion, store the key, encrypt something and then try to use that key in .NET to unencrypt the data?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2007 Mar 02, 2007

Copy link to clipboard

Copied

I gave that a try. It seems that the key generated by CF is not as standard as my .Net libraries are expecting. I'm still digging intothat one.

Thanks again for your help.
J

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 02, 2007 Mar 02, 2007

Copy link to clipboard

Copied

LATEST
It seems as if the DES keys are base64 encoded. not knowing anything about DES, I don't know if this is standard or not. You should be able to convert back to binary using a combination of the toBinary() and toString() CF functions. I think the following will convert base64 back into normal text:

toString(toBinary(myBase64String))

the results might be a little weird, though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation