Book Image

Haskell Data Analysis cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis cookbook

By: Nishant Shukla

Overview of this book

Step-by-step recipes filled with practical code samples and engaging examples demonstrate Haskell in practice, and then the concepts behind the code. This book shows functional developers and analysts how to leverage their existing knowledge of Haskell specifically for high-quality data analysis. A good understanding of data sets and functional programming is assumed.
Table of Contents (14 chapters)
13
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...