MD5 is (atleast when it was created) a standardized 1-way function that takes in data input of any form and maps it to a fixed-size output string, irrespective of the size of the input string.
Though it is used as a cryptographic hash function, it has been found to suffer from a lot of vulnerabilities.
The hash function generates the same output hash for the same input string. This means that, you can use this string to validate files or text or anything when you pass it across the network or even otherwise. MD5 can act as a stamp or for checking if the data is valid or not.
For example -
|Input String||Output Hash|
|computer science is amazing! I love it.||f3c5a497380310d828cdfc1737e8e2a3|
If you want to generate md5 checksum in nodejs, please follow this article-
For creating MD5 hash in the browser, we shall use the fastest implementation of md5 hash function created by Joseph Meyer.
It's actually very simple, just couple of things to do-
Import the library with the script tag (or download
md5.js and host it on your own CDN)
And then use it by assigning it to a variable
var md5hash = md5("Welcome to DebugPointer.com");
Alternatively, as part of ES6, you can also do-
$ npm install crypto-js
import MD5 from "crypto-js/md5"; console.log(MD5("Message").toString());
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>MD5</title> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/md5.js"></script> <script> var hash = CryptoJS.MD5("Message"); alert(hash); </script> </body> </html>
It's your choice, use what works best for you. You are good to go! Happy Coding
Please do not use this to hash passwords and store it in your databases, prefer SHA-256 or SHA512 or other superior cryptographic hash functions for the same.