528 B
528 B
title, type, tags, cover, dateModified
| title | type | tags | cover | dateModified | ||
|---|---|---|---|---|---|---|
| Encode string to Base64 | snippet |
|
laptop-journey | 2020-09-15T16:28:04+03:00 |
Creates a base-64 encoded ASCII string from a String object in which each character in the string is treated as a byte of binary data.
- Create a
Bufferfor the given string with binary encoding. - Use
Buffer.prototype.toString()to return the base-64 encoded string.
const btoa = str => Buffer.from(str, 'binary').toString('base64');
btoa('foobar'); // 'Zm9vYmFy'