.net - md5 hash for file without File Attributes -


using following code compute md5 hashs of files:

 private _md5hash string  dim _binarydata byte() = new byte(fileupload1.postedfile.inputstream.length) {}  fileupload1.postedfile.inputstream.read(_binarydata, 0, _binarydata.length)   dim md5 new system.security.cryptography.md5cryptoserviceprovider  dim md5hash() byte  md5hash = md5.computehash(me._binarydata)  me._md5hash = bytearraytostring(md5hash)    private function bytearraytostring(byval arrinput() byte) string      dim sb new system.text.stringbuilder(arrinput.length * 2)      integer = 0 arrinput.length - 1        sb.append(arrinput(i).tostring("x2"))      next      return sb.tostring().tolower   end function 

we getting different hashes depending on create-date , modify-date of file. storing hash , binary file in sql db. works fine when upload same instance of file. when save new instance of file db (with today's date create/modify) on file-system , check new hash versus md5 stored in db not match, , therefor fail duplicate check.

how can check file hash excluding file attributes? or there different issue here?

i suspect me._binarydata getting initialized more contents of file...

ultimately way hash can change if byte array changes.

another possibility character set / encoding differences when persist/restore file db.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -