react-native-crypto-js icon indicating copy to clipboard operation
react-native-crypto-js copied to clipboard

undefined SHA512

Open choijiho0021 opened this issue 2 years ago • 3 comments

is it not supported SHA algo? 스크린샷 2022-04-06 오전 11 08 14

import CryptoJS from 'react-native-crypto-js';
export const encryptSha = (text: string) => {
  console.log("result : ",  CryptoJS);
};

choijiho0021 avatar Apr 06 '22 02:04 choijiho0021

same here

LimeFlavoredMoon avatar Aug 01 '22 08:08 LimeFlavoredMoon

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);
};

NotRayor avatar Mar 29 '23 07:03 NotRayor

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)

DavidAPears avatar Jul 18 '23 17:07 DavidAPears