1

I have a Playready DRM manifest and am extracting the base64 encoded header from it, this part works fine.

However, when I try to decode the string in Javascript (client-side) via either atob or one of the other copy-paste implementations provided around here, there's a blank missing-character square between each expected character.

If I pipe the encoded string into base64 --decode in a terminal, I get the expected output.

Base64 encoded string: 0gIAAAEAAQDIAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AMQBpAHQASAAyAFIAaQAwAHMAawBXAC8AVgA3AHUAZwBZAGgALwA0AGgAZwA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBoAHUANgBOAFMAZABnADQAWAAyAFUAPQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAcwA6AC8ALwBsAGkAYwAuAHMAdABhAGcAaQBuAGcALgBkAHIAbQB0AG8AZABhAHkALgBjAG8AbQAvAGwAaQBjAGUAbgBzAGUALQBwAHIAbwB4AHkALQBoAGUAYQBkAGUAcgBhAHUAdABoAC8AZAByAG0AdABvAGQAYQB5AC8AUgBpAGcAaAB0AHMATQBhAG4AYQBnAGUAcgAuAGEAcwBtAHgAPAAvAEwAQQBfAFUAUgBMAD4APAAvAEQAQQBUAEEAPgA8AC8AVwBSAE0ASABFAEEARABFAFIAPgA=

base64 -decode output: ��<WRMHEADER xmlns="http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader" version="4.0.0.0"><DATA><PROTECTINFO><KEYLEN>16</KEYLEN><ALGID>AESCTR</ALGID></PROTECTINFO><KID>1itH2Ri0skW/V7ugYh/4hg==</KID><CHECKSUM>hu6NSdg4X2U=</CHECKSUM><LA_URL>https://lic.staging.drmtoday.com/license-proxy-headerauth/drmtoday/RightsManager.asmx</LA_URL></DATA></WRMHEADER>

Javascript output: ҂����Ȃ<�W�R�M�H�E�A�D�E�R� �x�m�l�n�s�=�"�h�t�t�p�:�/�/�s�c�h�e�m�a�s�.�m�i�c�r�o�s�o�f�t�.�c�o�m�/�D�R�M�/�2�0�0�7�/�0�3�/�P�l�a�y�R�e�a�d�y�H�e�a�d�e�r�"� �v�e�r�s�i�o�n�=�"�4�.�0�.�0�.�0�"�>�<�D�A�T�A�>�<�P�R�O�T�E�C�T�I�N�F�O�>�<�K�E�Y�L�E�N�>�1�6�<�/�K�E�Y�L�E�N�>�<�A�L�G�I�D�>�A�E�S�C�T�R�<�/�A�L�G�I�D�>�<�/�P�R�O�T�E�C�T�I�N�F�O�>�<�K�I�D�>�1�i�t�H�2�R�i�0�s�k�W�/�V�7�u�g�Y�h�/�4�h�g�=�=�<�/�K�I�D�>�<�C�H�E�C�K�S�U�M�>�h�u�6�N�S�d�g�4�X�2�U�=�<�/�C�H�E�C�K�S�U�M�>�<�L�A�_�U�R�L�>�h�t�t�p�s�:�/�/�l�i�c�.�s�t�a�g�i�n�g�.�d�r�m�t�o�d�a�y�.�c�o�m�/�l�i�c�e�n�s�e�-�p�r�o�x�y�-�h�e�a�d�e�r�a�u�t�h�/�d�r�m�t�o�d�a�y�/�R�i�g�h�t�s�M�a�n�a�g�e�r�.�a�s�m�x�<�/�L�A�_�U�R�L�>�<�/�D�A�T�A�>�<�/�W�R�M�H�E�A�D�E�R�>�

Does anyone know why this is happening or how to combat this? I assume it's the character set, but trying others yields similar results.

EDIT
SO has displayed the Javascript output string properly (i.e. How it should be in my program) so perhaps I'm not escaping it properly or something? Here's how the editor showed it to me when I pasted it in the first time: JS Output

EDIT 2 After the first edit, SO is now showing the wierd characters again...

2
  • Sounds like it's UTF-16 encoded, did you try that? This question might help stackoverflow.com/questions/14592364/… Commented Jul 10, 2017 at 8:38
  • @JeffUK You were right! Thank you. Commented Jul 10, 2017 at 8:56

1 Answer 1

2

Your data seems to be encoded UTF-16 with BOM. Using function found in UTF-16 to UTF-8 conversion in JavaScript it seems you could have your data in UTF-8 / ASCII using

decodeUTF16LE(atob(yourString)).slice(5) // .slice(5) = remove BOM
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.