【Node】node中如何使用btoa和atob

【Node】node中如何使用btoa和atob

在我的node.js应用程序中,如何使用btoaatob

尝试了‘btoa-atob’模块不好使,因为它不导出编程接口,它只提供命令行实用程序。

如果你需要转换为Base64,你可以使用Buffer:

console.log(Buffer.from('Hello World!').toString('base64'));

反向(假设您正在解码的内容是utf8字符串):

console.log(Buffer.from(b64Encoded, 'base64').toString());

 

原创文章,作者:ciding,如若转载,请注明出处:https://blog.ciding.cc/btoa-atob.html,侵权请联系删除,谢谢

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注