import { NitroModules } from 'react-native-nitro-modules' import type { Digest } from './specs/Digest.nitro' import { bufferToInt8Array, int8ArrayToBuffer } from './utils/HybridInterop' export interface XDigestService { sha256(data: Int8Array): Promise sha512(data: Int8Array): Promise } const hybridDigest = NitroModules.createHybridObject('Digest') export const DigestService: XDigestService = { async sha256(data: Int8Array): Promise { const res = await hybridDigest.sha256(int8ArrayToBuffer(data)) return bufferToInt8Array(res) }, async sha512(data: Int8Array): Promise { const res = await hybridDigest.sha512(int8ArrayToBuffer(data)) return bufferToInt8Array(res) }, }