Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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.
 
PREVIOUS NEXT
Tagged: #convert #buffer #javascript
ADD COMMENT
Topic
Name
9+3 =