Skip to content

Instantly share code, notes, and snippets.

@reosablo
Created April 28, 2021 14:26
Show Gist options
  • Select an option

  • Save reosablo/3adea54cfbe65757048886ac8a9c34ea to your computer and use it in GitHub Desktop.

Select an option

Save reosablo/3adea54cfbe65757048886ac8a9c34ea to your computer and use it in GitHub Desktop.
JavaScript: BigInt <=> BASE64 (Little Endian) Codec
export default a=>[...atob(a)].reduceRight((n,b)=>(n<<8n)+BigInt(b.charCodeAt(0)),0n)
export default n=>{let b='';do{b+=String.fromCharCode(Number(n%256n))}while(n>>=8n);return btoa(b)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment