react-native-crypto-js
react-native-crypto-js copied to clipboard
undefined SHA512
is it not supported SHA algo?
import CryptoJS from 'react-native-crypto-js';
export const encryptSha = (text: string) => {
console.log("result : ", CryptoJS);
};
same here
same here
react-native-crypto-js library did not implement SHA512.
older versions of crypto-js also work with react native. It can be solved using crypto-js as follows.
import CryptoJS from 'crypto-js';
export const encryptSha = (text: string) => {
return CryptoJS.SHA512(text).toString(CryptoJS.enc.Base64);
};
export const decrypt = (inputKey: string, encryptStr?: string) => {
if (encryptStr === undefined) {
console.log('@@@ decrypt str undefined');
return '';
}
const key = CryptoJS.enc.Utf8.parse(String(inputKey).padStart(16, ' '));
const iv = CryptoJS.enc.Utf8.parse(String(inputKey).padStart(16, ' '));
return CryptoJS.AES.decrypt(encryptStr, key, {iv}).toString(CryptoJS.enc.Utf8);
};
Same here. I've lost the best part of a day on this. Any help greatly appreciated.
import CryptoJS from "react-native-crypto-js";
const signature = CryptoJS.HmacSHA256(
`${encodedHeader}.${encodedPayload}`,
secret
);
Throws the error:
WARN Possible Unhandled Promise Rejection (id: 0):
TypeError: _reactNativeCryptoJs.default.HmacSHA256 is not a function. (In '_reactNativeCryptoJs.default.HmacSHA256(encodedHeader + "." + encodedPayload, secret)', '_reactNativeCryptoJs.default.HmacSHA256' is undefined)