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

Base64 to string

Participant ,
Mar 21, 2008 Mar 21, 2008

Copy link to clipboard

Copied

Hi,

I have a text that has been converted using ToBase64 and I am trying to convert it back to string. I am trying to use BinaryDecode with Base64 encoding to convert it but it keeps telling me that text must be valid binary object?
Please help!
TOPICS
Advanced techniques

Views

879

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
Contributor ,
Mar 21, 2008 Mar 21, 2008

Copy link to clipboard

Copied

"ToString" function?

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
Contributor ,
Mar 21, 2008 Mar 21, 2008

Copy link to clipboard

Copied

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
Participant ,
Mar 21, 2008 Mar 21, 2008

Copy link to clipboard

Copied

ToString on it's own doesn't work, I can make it work with tostringToBinary(text)) but Adobe documentation recommends to use BinaryDecode instad of the ToBinary

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
Contributor ,
Mar 21, 2008 Mar 21, 2008

Copy link to clipboard

Copied

What I have seen that after getting the binary version you just need to use ToString to convert into string "text" format.

<cfset yourText = toString(toBinary(YourData64))>

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
Community Expert ,
Mar 21, 2008 Mar 21, 2008

Copy link to clipboard

Copied

TiGGi wrote:
I have a text that has been converted using ToBase64 and I am trying to convert it back to string. I am trying to use BinaryDecode with Base64 encoding

Use BinaryEncode() not BinaryDecode()
stringData = BinaryEncode(toBinary(yourBase64Data), "base64")


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
Valorous Hero ,
Mar 21, 2008 Mar 21, 2008

Copy link to clipboard

Copied

TiGGi wrote:
> I have a text that has been converted using ToBase64 and I am trying to convert it back to string.

Your question is confusing. Base64 text is a string. Do you mean you want to convert a base64 string back into binary? As BKBK mentioned, BinaryEncode will convert binary data to base64 and BinaryDecode will convert base64 back into binary. Do you understand the difference?

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
Participant ,
Mar 24, 2008 Mar 24, 2008

Copy link to clipboard

Copied

cfSearching

Text was converted using toBase64 now I need to convert it back to text again.

I used toString(ToBinary(base64text)) to convert it back to text. My question was since CF documentation recommends using BinaryDecode instead of ToBinary, how do I use BinaryDecode? I was not able to figure it out.

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
Contributor ,
Mar 24, 2008 Mar 24, 2008

Copy link to clipboard

Copied

<cfset myText = "This is my Unicode Text ğĞüÜıİşŞöÖçÇ">
<cfdump var="#myText#">
<br />
<cfset mybase64 = toBase64(myText)>
<cfdump var="#mybase64#">
<br />
<cfset myTextBack = toString(ToBinary(mybase64))>
<cfdump var="#myTextBack#">

This works.

Same thing with BineryDecode

<cfset myTextBack = toString(BinaryDecode((mybase64),'Base64'))>

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
Valorous Hero ,
Mar 24, 2008 Mar 24, 2008

Copy link to clipboard

Copied

LATEST
TiGGi wrote:
I used toString(ToBinary(base64text)) to convert it back to text. My question was since CF documentation recommends using BinaryDecode instead of ToBinary, how do I use BinaryDecode? I was not able to figure it out.

IIRC I believe they are referring to binary data specifically. For text you may still need to use the previous functions.

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