4 years ago (2017-03-08)  Algorithm language |   First to comment  86 
post score 0 times, average 0.0

Most recent guests have used React Native's own blog client. When the client invokes the WordPress Rest API, some operations require HTTP authentication. In HTTP authentication, the "Authorization" field is added to the header of the HTTP request. The contents of the field when the user name: base64 encoding of the password

Environmental dependence

The Base64 codec algorithm is supported in the Nodejs buffer component. First we need to run the command line to install the buffer dependencies in the root directory of the React Native project: npm install buffer --save After installing, the app.json in the root directory of React Native The dependencies will automatically add the following one:

Base64 support in React Native

Base64 support in React Native

How to use


Var Buffer = require('buffer').Buffer


Var base64Str= new Buffer(rawStr).toString('base64');



Buffer project home page:

For more ways to use buffers, refer to the Buffer home page: https://github.com/feross/buffer


This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/adding-base64-react-native-support-2.html

Post comment


No Comment


Forget password?