Use a combination of SHA1+MD5 -


i'm trying use secure way create checksum files (larger 10gb !).

sha256 secure enough me algorithm process expensive , not suitable. know both sha1 , md5 checksums insecure through collisions.

so think fastest , safest way combining md5 sha1 : sha1+md5 , don't think there way file (collision) same md5 , sha1 both @ same time .

so combining sha1+md5 secure enough file checksum? or there attack collision ?

i use c# mono in 2 way (bufferstream , without bufferedstream)

    public static string getchecksum(string file)     {         using (filestream stream = file.openread(file))         {             var sha = new sha256managed();             byte[] checksum = sha.computehash(stream);             return bitconverter.tostring(checksum).replace("-", string.empty);         }     }      public static string getchecksumbuffered(stream stream)     {         using (var bufferedstream = new bufferedstream(stream, 1024 * 32))         {             var sha = new sha256managed();             byte[] checksum = sha.computehash(bufferedstream);             return bitconverter.tostring(checksum).replace("-", string.empty);         }     } 

update 1: mean sha1 hash + md5 hash. first calculate sha1 of file calculate md5 of file add 2 sting together.

update 2 :

as @zaph mentioned implement code(c# mono) again according read here doesn't make code fast said ! makes speed 4.6 gb file (approximate) 12mins 8.~ mins sha1+md5 takes me less 100 secs file. still think isn't right use sha256 instead.

there should small difference between sha-256 , combination of md5+sha1.

the way know benchmark:

on desk top:
sha-256: 200 mb/s
md5: 470 mb/s
sha1: 500 mb/s (updated, incorrect)
md5+sha1 240 mb/s

these times hashing, disk read time not included. tests done 1mb buffer , averaged on 10 runs. language "c" , library used apple's common crypto. cpu 2.8 ghz quad-core intel xeon (2010 macpro, laptop faster).

in end 23% faster use combined md5+sha1.

note: intel processors have instruction can used make crypto operations faster. not implementations utilize these instructions.

youmight try native implementations such sha256sum.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -