Skip to content

Instantly share code, notes, and snippets.

Created July 12, 2019 11:19
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Calculate MD5 hash of file without the need to download it ( it's still downloads, bust just in the browser)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
<html lang="en">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src=""></script>
<script type="text/javascript">
function calculateMD5(blob) {
return new Promise((resolve) => {
const reader = new FileReader();
reader.onloadend = function () {
var wordArray = CryptoJS.lib.WordArray.create(reader.result),
hash = CryptoJS.MD5(wordArray).toString();
function downloadAndCreateHash(){
const hashResultDiv = document.getElementById('hash-result')
.then(function(response) {
return response.blob()
.then(blob => {
return calculateMD5(blob)
.then(hash => {
hashResultDiv.innerHTML = hash
console.log(`Hash of the file is: ${hash}`)
.catch(err => {
hashResultDiv.innerHTML = err
<body style="text-align: center;">
<h1>Enter the url of the file:</h1>
<input id="url-input" type="text" oninput="downloadAndCreateHash()" style="width: 400px">
<h2>MD5 hash of your file is:</h2>
<div id="hash-result">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment