Please provide the following:
- SDK Version: 45.0.0
- Platforms(Android/iOS/web/all): Android/iOS
- Add the appropriate “Tag” based on what Expo library you have a question on.
I’m working with the Node crypto library in my web application and expo-crypto in my app. I need to have the same functionality in both. The value from the Node crypto library is correct but for some reason I’m getting another value with expo-crypto.
Currently the web solution is working as expected.
const randomData = 'XTXpQWATVzlHSp2ZjvmoAfvXYDtT3O1q4SYFIDyPXardJhiLbC/tiw==';
const hashedValue = crypto.createHash('sha512').update(randomData).digest('hex');
The hashed value above is 932ed33fb9688dce41620b2a835d353598d410f76fdc0de34b057393443cffcb3733360cf18327df66d8dc120f94dd1c28741f81b098f8dee26c1a0b0a37d4e1
My expo app solution is not returning the same value as the web solution:
import Crypto from 'expo-crypto'
const randomData = 'XTXpQWATVzlHSp2ZjvmoAfvXYDtT3O1q4SYFIDyPXardJhiLbC/tiw==';
const hashedValue = await Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA512, randomData);
This hashed value, from expo-crypto
is 270a2e3a3ea41fca841611e2dc539ac6110a9d64cc68cc16165e25020b1c3cec36d3d1680009e999c8f934a2926f0e12be1a1bd6664235cc08da02809028b10c
Ideally they would both return the same value, any ideas on what is going on here? I also posted this to stack overflow