I'm new to C#
- How do i hash files with C#
- What is available ? (md5, crc, sha1, etc)
- Is there an interface i should inherit?
Basically i want to checksum multiple files and store it in a db along with using two of my own checksums/hashes.
I'm new to C#
- How do i hash files with C#
- What is available ? (md5, crc, sha1, etc)
- Is there an interface i should inherit?
Basically i want to checksum multiple files and store it in a db along with using two of my own checksums/hashes.
You can utilize .NET classes under System.Security.Cryptography
No you don't have to. Take a look at HashAlgorithm.Create(...)
What are you trying to achieve with the hashes? If you're trying to actually guarantee that nobody maliciously altered the files, please don't implement your own checksum or hash. You'll probably make some mistake and someone will be able to tamper with a file and have the checksums still match. Use a good hash function like SHA-256.
Snippet
See also SHA1CryptoServiceProvider or MD5CryptoServiceProvider.
CRC is not available -- it's more efficient to create your own.