Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const _fromCharCode = String.fromCharCode
- export function pack_base64(arr) {
- let res=''
- const u8 = new Uint8Array(arr.buffer || arr)
- const len = u8.byteLength
- for (let i=0; i<len; i++)
- res += _fromCharCode(u8[i])
- return window.btoa(res)
- }
- const _charCodeAt = ''.charCodeAt
- export function unpack_base64(str_b64) {
- const sz = window.atob(str_b64)
- const len = sz.length
- const res = new Uint8Array(len)
- for (let i=0; i<len; i++)
- res[i] = _charCodeAt.call(sz, i)
- return res
- }
Add Comment
Please, Sign In to add comment