Book Image

Haskell Data Analysis Cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis Cookbook

By: Nishant Shukla

Overview of this book

Table of Contents (19 chapters)
Haskell Data Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Running a cryptographic checksum on a file


One of the most effective methods to determine whether a file on a computer is different from another file elsewhere is by comparing their cryptographic hashes. If the two hashes are equal, it's only highly probable that the files are equal, but not strictly necessary due to the possibility of collisions.

After downloading a file online, such as Arch Linux from https://www.archlinux.org/download, it is a good idea to ensure the cryptographic hashes match up. For example, have a look at the following screenshot:

The preceding screenshot shows the corresponding hashes for the Arch Linux download as of late May, 2014.

Notice how both MD5 and SHA1 hashes are provided. This recipe will show how to compute these hashes in Haskell to ensure data integrity.

We will compute the SHA256, SHA512, and MD5 hashes of its own source file.

Getting ready

Install the Crypto.Hash package from Cabal as follows:

$ cabal install cryptohash

How to do it…

Create a file named...