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

Base64 to string

Participant ,
Mar 21, 2008 Mar 21, 2008
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
994
Translate
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
"ToString" function?

Translate
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
Translate
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
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
Translate
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
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))>
Translate
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
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")


Translate
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
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?
Translate
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
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.
Translate
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
<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'))>

Translate
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
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.
Translate
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