Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
24i
Level 7

Decoding Base64 string fails

Hi,

I'm trying to decode a Base64 string using the FromBase64String(s as String) from the roByteArray object:
https://sdkdocs.roku.com/display/sdkdoc/ifByteArray

Our customer is sure that the string that we receive is valid base-64 encoding, as it works on other platforms (tvOS, Android, etc)
However when I try to get a readable string out of I get: ???????0??????1?0   ??+?????
blob = CreateObject("roByteArray")
blob.FromBase64String(apiData.data.Mid(startStr, 20))

print blob.ToAsciiString()


The string I tried to decode:
MIIZEgYJKoZIhvcNAQcCoIIZAzCCGP8CAQExCzAJBgUrDgMCGgUAMIIIvwYJKoZIhvcNAQcBoIIIsASCCKwwggioAgECMIIBBTCCAQECAQMCAQEEJDQyRTlBMzI1LUQ1MzYtMzRCNS05RjVDLTBGQkYzQkQyMUU1RTF6MCMMIWNvbS5hZG9iZS5mbGFzaGFjY2Vzcy5yaWdodHMucGxheTBTDCljb20uYWRvYmUuZmxhc2hhY2Nlc3MucmlnaHRzLmxpY2Vuc2VVc2FnZaAmMSQwEAYJKoZIhvcvAwYCoAMBAf8wEAYJKoZIhvcvAwYOoAMBAf+gCgwINC4wLjA0MTShDQwLZnViby1wb2xpY3mjMjEwMC4MKmNvbS5hZG9iZS5mbGFzaGFjY2Vzcy5hdHRyaWJ1dGVzLmFub255bW91czEApgMBAf+oAwEB/zGCBUgwggVEMXoMeGh0dHA6Ly9wcmltZXRpbWUubGljZW5zZS5pc3RyZWFtcGxhbmV0LmNvbS85ZDNlZDc2MC0zYmE5LTQwNDItYjRhNC0wN2UwZDgwNjkyMDAvOTdjZWYxMTdkNjkwNDJjYjk4Nzg0ZDhiY2JlNjc2OTEwMDAwMDAwMDCCBMQwggOsoAMCAQICEAfujo6ObHFsvfusFAJGKPcwDQYJKoZIhvcNAQELBQAwZTELMAkGA1UEBhMCVVMxIzAhBgNVBAoTGkFkb2JlIFN5c3RlbXMgSW5jb3Jwb3JhdGVkMT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b2JlIEZsYXNoIEFjY2VzcyBDdXN0b21lciBCb290c3RyYXAgQ0ECEBQOAPB1InYwOIgQz0rUKuYwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE3MDYyODAwMjkyMVowIwYJKoZIhvcNAQkEMRYEFO+17z6PpAcCHWWdIB10a4ZE+WhFMA0GCSqGSIb3DQEBAQUABIGAHijUQkE2XZayvDSjI4LhOOD4hq59XejMzSRhXdSGg2ya06gaBuqCuiAoie9QLsfEEPBKJ3NXUGfu5NTIHe/filJhRJaW/xrH2WPNvoKQzDMf7RT67Xd3YzyCYA4CxjwUFJHjkhFPzMXHawnLvBqSU/r9LzfxBFIxeCeRhfcgkbw=


any thoughts?
0 Kudos
5 Replies
destruk
Level 10

Re: Decoding Base64 string fails

The string you are decoding has extended ascii characters in the output - anything >128 will show as a "?" if you are trying to print it or stick it into a label.  But the decode option ought to work.  Does Roku play Flash Streams?
0 Kudos
RokuPam
Level 7

Re: Decoding Base64 string fails

Hello,

We do not support flash streams.

Have you tried using another font (i.e. system font) that supports your characters? I'd also recommend reviewing our Encoding Guidelines from the SDK docs here.
0 Kudos
24i
Level 7

Re: Decoding Base64 string fails

I was already afraid this had something to do with the extended ASCII characters not being supported. 
This string is from the manifests that we receive for the streams and contains a token that we have to use.
I will contact our client about this, thank you!
0 Kudos
Roku Employee
Roku Employee

Re: Decoding Base64 string fails

"24i" wrote:
I was already afraid this had something to do with the extended ASCII characters not being supported. 
This string is from the manifests that we receive for the streams and contains a token that we have to use.


You should be able to work with the binary data in the roByteArray assuming the base64 decode was successful.
However, to use roByteArray ToAsciiString, the binary data must be either 7-bit ASCII or valid UTF-8 data,
as noted in the documentation.

And as RokuPam noted, if you are using non-Latin or "unusual" characters, the console you are printing to would
need to be set up to support UTF-8, including whatever font support might be needed to show the character glyphs.
0 Kudos
Roku Employee
Roku Employee

Re: Decoding Base64 string fails

"24i" wrote:
any thoughts?

Yes - this is base64-encoded binary. Go to say https://www.base64decode.org/ and decode the string, look at the result file and you will see it's not a proper text string, while it contains texts ("com.adobe.flashaccess.rights." something-something). I am not sure what it is - signed token or certificate chain - but text it is not. So you shouldn't expect ToAsciiString() making sense of it.
0 Kudos