decrypt ,md5 encrypt data in react native

3.7k Views Asked by At

I want to know, how can I decrypt, md5 encrypt data in react native. May you help me. I can't fine any tutorial in web. I added md5 library for encrypt but I can't decrypt that cod. If you know about encrypt too, please explain that. How can I use in react native cod. Thanks

1

There are 1 best solutions below

0
kelalaka On BEST ANSWER

MD5 is not an encryption algorithm! It is a message-digest algorithm used as a hash function.

Cryptographic hash functions are one-way, deterministic, compression functions that behave randomly.

  • One-way means no inverse function exists,
  • deterministic means the same inputs result in the same output,
  • compression means the input size can be any length but the output size is fixed by the hash function. MD5 has a 128-bit digest size.
  • Random means the hash function output is unpredictable before computing.

The MD5 pre-image resistance theoretically is broken bu not practically. Instead of the generic preimage attack with 2128 complexity, there is an attack that requires 2123.4 complexity. MD5, however, is not practically broken. You cannot reach the 123-bit search space in a meaningful time. Consider the collective power of BitCoin miners; in 2020/1/17 they reached 126.1314 Exahashes per second, that makes

  • 267 SHA256 double hashes in a second, and
  • 292 SHA256 double hashes in a year. So you need 221 years with that power.

However, you can find collisions for MD5. There are two good libraries two produce collisions; corkami or hashclash

For encryption, use AES or ChaCha20 with proper modes like AES-GCM or AES-GCM-SIV and ChaCha20-Poly1305 bot provides authenticated encryption that you will get Confidentiality, Integrity, and authentication.