React native 如何在react native中加密和解密捕获的图像?
我是英语初学者。我能够使用react native image picker捕获图像,并且能够将捕获的照片上传到aws s3。但是,我想在android设备中加密或散列捕获的图像,在上传之前,我需要解密它们。这些照片必须在手机内加密/散列,只有通过我的应用程序我才需要解密。我如何实现这一点 有两种方法, 在takePic方法中,我希望在存储到设备之前对其进行加密,在upload方法中,我希望在上传之前对其进行解密。我用谷歌搜索了一下。但我没有得到任何关于这方面的适当文件 你能帮我做这件事吗 我的密码是React native 如何在react native中加密和解密捕获的图像?,react-native,encryption,React Native,Encryption,我是英语初学者。我能够使用react native image picker捕获图像,并且能够将捕获的照片上传到aws s3。但是,我想在android设备中加密或散列捕获的图像,在上传之前,我需要解密它们。这些照片必须在手机内加密/散列,只有通过我的应用程序我才需要解密。我如何实现这一点 有两种方法, 在takePic方法中,我希望在存储到设备之前对其进行加密,在upload方法中,我希望在上传之前对其进行解密。我用谷歌搜索了一下。但我没有得到任何关于这方面的适当文件 你能帮我做这件事吗 我的
import React, { Component } from "react";
import {
Platform,
StyleSheet,
Alert,
Text,
TouchableOpacity,
View,
Picker,
Animated,
Easing,
Image
} from "react-native";
import ImagePicker from "react-native-image-picker";
import { RNS3 } from "react-native-aws3";
export default class SecondScreen extends Component<Props> {
constructor(props) {
super(props);
this.state = {
file: "",
saveImages: []
};
}
takePic() {
const options = {
quality: 1.0,
maxWidth: 50,
maxHeight: 50,
}
ImagePicker.launchCamera(options,(responce)=>{
const file = {
uri: responce.uri,
name: responce.fileName,
method: "POST",
path: responce.path,
type: responce.type,
notification: {
enabled: true
}
};
this.state.saveImages.push(file);
});
}
_upload = saveImages => {
const config = {
keyPrefix: "uploads/",
bucket: "myBukectName",
region: "us-east-2",
accessKey: "***",
secretKey: "***",
successActionStatus: 201
};
this.state.saveImages.map(image => {
RNS3.put(image, config).then(responce => {
console.log(saveImages);
});
});
//once after upload is done delete from the gallary
};
render() {
return (
<View style={styles.container}>
<View style={styles.Camera}>
<TouchableOpacity onPress={this.takePic.bind(this)}>
<Text>Take Picture</Text>
</TouchableOpacity>
</View>
<View style={styles.Send}>
<TouchableOpacity onPress={() => this._upload()}>
<Text>Send</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
import React,{Component}来自“React”;
进口{
平台,
样式表,
警觉的,
文本,
可触摸不透明度,
看法
皮克,
有生气的
缓和,,
形象
}从“反应本族语”;
从“react native image picker”导入ImagePicker;
从“react-native-aws3”导入{RNS3};
导出默认类SecondScreen扩展组件{
建造师(道具){
超级(道具);
此.state={
文件:“”,
保存图像:[]
};
}
takePic(){
常量选项={
质量:1.0,
最大宽度:50,
最大高度:50,
}
ImagePicker.launchCamera(选项,(响应)=>{
常量文件={
uri:response.uri,
名称:response.fileName,
方法:“张贴”,
路径:response.path,
类型:response.type,
通知:{
已启用:true
}
};
this.state.saveImages.push(文件);
});
}
_上传=保存图像=>{
常量配置={
keyPrefix:“上传/”,
bucket:“myBukectName”,
地区:“us-east-2”,
accessKey:“***”,
秘钥:“***”,
成功状态:201
};
this.state.saveImages.map(image=>{
put(image,config).then(response=>{
console.log(保存图像);
});
});
//上传完成后,从gallary中删除
};
render(){
返回(
拍照
这个。_upload()}>
发送
);
}
}
我已经使用react-native-base64完成了这项工作,并且正在使用python在服务器端进行解密。(从文件中获取base64数据并对其进行解码。)
takePic(){
}
//set of other codes
const base64 = RNFS.writeFile(responce.uri, responce.data);
return base64;
//this will create the base64 image file