Somehow after spending a day on it I managed to convert an image file to BLOB through b64-to-blob. This attached link helped me to do so. I had done this in this way :
Step 1: import ImgToBase64 from 'react-native-image-base64';
Step 2: You have to install npm i -S base-64 (for encoding and decoding in atob, btoa)
Step 3: import {decode as atob, encode as btoa} from 'base-64'
Step 4: var b64toBlob = require('b64-to-blob'); , var baseStringSample;
Step 5: Make a function to convert your Image to base64
_convertImageToBaseSixFour() {
ImgToBase64.getBase64String('YOUR_IMAGE_PATH') // path to your image from local storage
.then((base64String) => {
baseStringSample = base64String,
})
.catch(err => Alert.alert('Error' + err));
}
Step 6:
// ****** CONVERT BASE64 TO BLOB ******* //
_imageToBlob(){
var byteCharacters = atob(baseStringSample);
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
byteArray = new Uint8Array(byteNumbers);
console.log("BYTEARRAY: " + byteArray);
}
}
Step 7: Then generated keys , did encryption and decryption through UInt8Array method in openpgp library
Step 8: Converted decrypted image to base64 and then base64 to Image , showed image in a Imageview.