actually I have a file, and I want to convert to MD5.
{data: "iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAYAAACAvzbMAAAAAX"
fileName: "test.png"
fileSize: 159000
height: 400
isVertical: true
originalRotation: 0
path: "/storage/emulated/0/Download/test.png"
type: "image/png"
uri: "content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDownload%2Ftest.png"
width: 400
}
I tried with these libraries:
import md5 from 'md5'
but when is executed return me this: 3449c9e5e332f1dbb81505cd739fbf3f
but when I executed: MD5 test.png in my Mac return me this: 01fd1175378be2d58dae81d934a5fe82
I need the md5 of file because the API I need to use, require this.
but when I use the result of the library(3449c9e5e332f1dbb81505cd739fbf3f) return me error.
but when I use the result of my mac(01fd1175378be2d58dae81d934a5fe82) return me succesful.
so, I want to know how I can convert this file to MD5 like terminal of my mac.
this is my all code of component
import React, { useState } from 'react'
import { View, Image } from 'react-native'
import ImagePickerRN from 'react-native-image-picker'
import md5 from 'md5'
//? components
import { Text, IconButton } from '../'
//? styles
import styles from './styles'
const ImagePicker = ({ onValueChange, ...otherProps }) => {
const [image, setImage] = useState()
const selectImage = async () => {
ImagePickerRN.showImagePicker((image) => {
if (image.didCancel) {
console.log('User cancelled image picker')
} else if (image.error) {
console.log('ImagePicker Error: ', image.error)
} else if (image.customButton) {
console.log('User tapped custom button: ', image.customButton)
} else {
const source = { uri: image.uri }
console.log({ md5: md5(image) })
setImage(source)
onValueChange(image)
// You can also display the image using data:
// const source = { uri: 'data:image/jpeg;base64,' + response.data };
}
})
}
return (
<View style={styles.container} {...otherProps}>
<Text bold style={styles.text}>
Image:
</Text>
{image ? (
<Image source={image} style={styles.image} />
) : (
<IconButton
icon='picture-o'
style={styles.image}
iconStyle={{ fontSize: 70 }}
onPress={selectImage}
/>
)}
</View>
)
}
export default ImagePicker