• Actually there's no need to eval/stringify it at all.

    atob/btoa will do exactly what you want... Just convert your raw data into a string on the PC (String.fromCharCode.apply(null, data)), and stick it through btoa.

    Then to decode, call atob - it'll give you a string, but you can convert that straight to a Uint8Array with: E.toUint8Array(atob(encoded_data))

    You might be able to do a little better (avoiding the new allocation for toUint8Array) but hopefully that'll be good enough for you. If you do it right you can make sure that encoded_data gets freed after atob but before toUint8Array

About

Avatar for Gordon @Gordon started