dataHash
Returns the file's content hash as recorded in the active C2PA manifest. This hash is used as a public input to the zero-knowledge proof.
Usage
import { VerifiableFile } from '@succinctlabs/react-native-zcam1';
const verifiable = new VerifiableFile(photoPath);
const hash = verifiable.dataHash();
console.log('Content hash:', hash);Returns
string | undefined - The manifest data hash (base64-encoded string), or undefined if not available.
Example
import { useState } from 'react';
import { Button, Text, View, StyleSheet } from 'react-native';
import { VerifiableFile } from '@succinctlabs/react-native-zcam1';
import { launchImageLibrary } from 'react-native-image-picker';
function HashDisplayScreen() {
const [hash, setHash] = useState<string>('');
const getHash = async () => {
const response = await launchImageLibrary({ mediaType: 'photo' });
const uri = response.assets?.[0]?.uri;
if (!uri) return;
try {
const verifiable = new VerifiableFile(uri);
const photoHash = verifiable.dataHash();
if (photoHash) {
setHash(`Hash: ${photoHash.substring(0, 32)}...`);
} else {
setHash('No hash available');
}
} catch (error: any) {
setHash(`Error: ${error.message}`);
}
};
return (
<View style={styles.container}>
<Button title="Get Photo Hash" onPress={getHash} />
{hash && <Text style={styles.hash}>{hash}</Text>}
</View>
);
}Notes
- The hash is computed from the photo's actual file content
- This hash is used as a public input when verifying the zero-knowledge proof
- The hash is base64-encoded for readability and compatibility
- Computed lazily on first access and cached for subsequent calls