Skip to content

Instantly share code, notes, and snippets.

View tconrado's full-sized avatar

Thiago Vincenzi Conrado tconrado

  • Foundry Digital
  • Brazil
View GitHub Profile
@chrisveness
chrisveness / base64.js
Last active May 6, 2023 02:55
Encode/decode ASCII string to/from base64
/**
* Encode string into Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648].
* As per RFC 4648, no newlines are added.
*
* Characters in str must be within ISO-8859-1 with Unicode code point <= 256.
*
* Can be achieved JavaScript with btoa(), but this approach may be useful in other languages.
*
* @param {string} str ASCII/ISO-8859-1 string to be encoded as base-64.
* @returns {string} Base64-encoded string.