React Native Password Encryption Decryption using Base64 Method Example

Password is a secret group of characters with symbols used to gain access into a certain place. Normally before the password encryption technique the password is saved as same typed form, Which can be easily readable via human eyes. Which is not safe for users. Now days the password is first convert into a fixed encrypted form which can be relabel by human eyes but not used to LOG-In because its converted. A most famous password encryption technique is known as Base64 encryption which is used by hundreds of websites and mobile applications to store their password. In this tutorial we would learn about Password Encryption Decryption using Base64 Method in React Native Android iOS Example tutorial.

Content in this project Password Encryption Decryption using Base64 Method in React Native Android iOS Example:

1. Before getting started the coding we need to install a NPM library named as js-base64. This library has almost 4.6 million weekly downloads and most popular among developers. So open your react native project folder in command prompt or Terminal and execute below command to install the js-base64 library. base64 library comes in pure JavaScript code so there is no need to use the link command after done installation.

Screenshot of CMD:


2. Open your project’s App.js file and import StyleSheet, Text, View, TouchableOpacity and TextInput component.

2. Import Base64 component from js-base64 library in your project.

3. Create constructor() method in your app’s main export default class and inside it create 2 States named as Password_Holder and update_data.

Password_Holder : Is used to hold the entered password text in TextInput component.

update_data : Is used to hold the password after applying the Encryption.

4. Create a function named as encrypt_password(). Inside the function we would use the Base64 component to convert the TextInput entered string in Base64 encryption and store the encrypted password into state.

5. Create a function named as decrypt_password(). Inside the function we would again use the Base64 component to Decrypt the encrypted string into normal format and store in State.

6. Creating 1 TextInput, 2 Buttons using TouchableOpacity and 1 Text component in render’s return block.

7. Creating Style.

8. Complete source code for App.js File :

Screenshots:

Password Encryption Decryption using Base64 Method