How to do Base64 encoding in node.js?

前端 未结 7 1289
渐次进展
渐次进展 2020-11-22 16:46

Does node.js have built-in base64 encoding yet?

The reason why I ask this is that final() from crypto can only output hex, binary or ascii

7条回答
  •  耶瑟儿~
    2020-11-22 17:30

    I have created a ultimate small js npm library for the base64 encode/decode conversion in Node.js.

    Installation

    npm install nodejs-base64-converter --save
    

    Usage

    var nodeBase64 = require('nodejs-base64-converter');
    
    console.log(nodeBase64.encode("test text")); //dGVzdCB0ZXh0
    console.log(nodeBase64.decode("dGVzdCB0ZXh0")); //test text
    

提交回复
热议问题