js-file-md5

Get a MD5 hash from a file with Javascript.

Usage no npm install needed!

<script type="module">
  import jsFileMd5 from 'https://cdn.skypack.dev/js-file-md5';
</script>

README

js-file-md5

Get a MD5 hash from a file with Javascript.

Usage

HTML

<input id="example-file" type="file" />

Javascript

import md5 from 'js-file-md5';

const fileInput = document.querySelector('#example-file');

fileInput.addEventListener('change', function(e) {
  const file = e.target.files[0];

  md5(file).then(hash => {
    console.log(hash); // md5 hash
    console.log(btoa(hash)); // base64 encode
  }).catch(error => {
    throw error;
  });
});