“Buffer NODEJS. Dari Base64” Kode Jawaban

Konversi buffer ke 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='
Crinfarr

Buffer NODEJS. Dari 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"
God Of Coding

Buffer NODEJS. Dari 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=
God Of Coding

Jawaban yang mirip dengan “Buffer NODEJS. Dari Base64”

Pertanyaan yang mirip dengan “Buffer NODEJS. Dari Base64”

Lebih banyak jawaban terkait untuk “Buffer NODEJS. Dari Base64” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya