O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Verify That Data Hasn’t Changed

Problem

You want to ensure that a file or combination of data files cannot be undetectably altered.

Solution

Use a HashAlgorithm class to create a hash code based on the data, and store this hash code to use for future comparisons.

Discussion

Encryption prevents malicious users from reading your data, but it doesn’t stop them from tampering with it. Instead, you need a way to validate data and detect whether it has been altered. This is the role played by hash codes.

A hash code algorithm generates a small (typically about 20-byte) binary fingerprint for any data that can be represented as a sequence of bytes. Hash codes are cryptographically secure, which means that it’s extremely difficult for a malicious user to create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required