Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

convert buffer to base64 javascript

var buffer = Buffer.from('hello');//create a buffer of the text "hello"
//right now, buffer == <Buffer 68 65 6c 6c 6f>
var string64 = buffer.toString('base64');
//the .toString operator can set encoding
//string64 == 'aGVsbG8='
//Alternatively, do it all at once:
var string64A = Buffer.from('hello').toString('base64')
//This works exactly the same as the previous method, but only uses 1 variable.
Comment

nodejs buffer.from base64

//--------------- HOW TO DECODE BASE64 ON NODEJS ----------------------
//create a buffer of the text "Hello World"
var buffer = Buffer.from('SGVsbG8gV29ybGQ=', 'base64');
//buffer result is: <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>

var string64 = buffer.toString('ascii');
// .toString('ascii') allow to decode base64
// result is: "Hello World"

// Can be use combined together like these
console.log(Buffer.from('SGVsbG8gV29ybGQ=', 'base64').toString('ascii'));
// result is: "Hello World"
Comment

nodejs buffer.from base64

//--------------- HOW TO ENCODE BASE64 ON NODEJS ----------------------
//create a buffer of the text "Hello World"
var buffer = Buffer.from('Hello World');
//buffer result is: <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>

var string64 = buffer.toString('base64');
// .toString('base64') allow to encode it to base64
// result is: SGVsbG8gV29ybGQ=

// Can be use combined together like these
console.log(Buffer.from('Hello World').toString('base64'));
// result is: SGVsbG8gV29ybGQ=
Comment

PREVIOUS NEXT
Code Example
Javascript :: using multiparty with node js express 
Javascript :: javascript format date time 
Javascript :: check many keys in objects 
Javascript :: remove item from array by value 
Javascript :: dataset js 
Javascript :: MongoParseError: options buffermaxentries, usefindandmodify, usecreateindex are not supported 
Javascript :: axios cancel request 
Javascript :: chart js small bars too thin 
Javascript :: discord.js remove every role a user has 
Javascript :: what is synchronous and asynchronous in javascript 
Javascript :: how to set a string 
Javascript :: scrollto is not a function javascript 
Javascript :: days array in js 
Javascript :: javascript tick marks 
Javascript :: electron disable scrollbar 
Javascript :: add tab to textarea 
Javascript :: javascript remove first character from array list 
Javascript :: javascript after 2 months date find 
Javascript :: difference between the `.append()` method and the `.appendChild()` method 
Javascript :: regex search for all math operators 
Javascript :: get element innerhtml jquery 
Javascript :: app use morgan 
Javascript :: how to make a game in unity with javascript 
Javascript :: trailing zeros in factorial js 
Javascript :: get the most recent records in mongoose 
Javascript :: nest navigation react navigation 
Javascript :: javascript react useState update object 
Javascript :: how to capture a thumbnail from a video 
Javascript :: string concatenation javascript 
Javascript :: nodejs emit event from class 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =