I am trying to use a safe way to create a checksum for files (over 10 GB!).
SHA256 is safe enough for me, but this algorithm is so expensive and not suitable. Well, I know that SHA1 and MD5 checksums are unsafe due to collisions.
So, I believe that the fastest and safest way is combining MD5 with SHA1, for example: SHA1 + MD5, and I donβt think there is a way to get a file (Collision) with the same MD5 and SHA1 at the same time.
So, is SHA1 + MD5 safe enough for a checksum file? or is there any attack, such as a collision?
I use C # mono in two ways (Bufferstream and 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);
}
}
1:
SHA1 + MD5. SHA1 , MD5 , .
2:
@zaph, (# MONO) , , ! 4,6 () 12 8. ~ , sha1 + md5 100 . - SHA256 .