The returned value of md5.js encrypted video is the same?

guys, I"m doing a js slice to upload a file. The front end passes a unique logo of the file. After using md5, I found that different videos print the same encryption value? This is very embarrassing, Google has not solved for a long time!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="http://cdn.bootcss.com/blueimp-md5/1.1.0/js/md5.min.js"></script> 
</head>
<body>
    <form action="">
        <input type="file" id="test" multiple="multiple"/>
    </form>
    <script>
        window.onload=function(){
            let upInput=document.getElementById("test");
            upInput.addEventListener("change",function(){
                var file = this.files[0];
                var reader = new FileReader();
                reader.readAsArrayBuffer(file);
                reader.addEventListener("load", function(e) {
                    var res = e.target.result;
                    console.log(res,"res")
                    var md5Info=md5(res)
                    console.log(md5Info,"md5Info")
                });
            })
        }
    </script>
</body>
</html>

this is a temporary demo,. You can run it.

Mar.16,2021

 function md5 (string, key, raw) {
    ...
 }   

blueimp-md5.js

res is a ArrayBuffer , and md5 (res) means md5 (res.toString ()) / / md5 ('[object ArrayBuffer]') , so it's all the same.
either changes to string , or uses the md5 module that supports ArrayBuffer .

Menu