1 -- Copyright (C) 2008 David Roundy
3 -- This program is free software; you can redistribute it and/or modify
4 -- it under the terms of the GNU General Public License as published by
5 -- the Free Software Foundation; either version 2, or (at your option)
8 -- This program is distributed in the hope that it will be useful,
9 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
10 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 -- GNU General Public License for more details.
13 -- You should have received a copy of the GNU General Public License
14 -- along with this program; see the file COPYING. If not, write to
15 -- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 -- Boston, MA 02110-1301, USA.
18 module Main
(main
) where
20 import System
( getArgs )
22 import qualified Data
.ByteString
as B
23 import SHA1
( sha1PS
)
24 import Crypt
.SHA256
( sha256sum
)
27 main
= do args
<- getArgs
29 ("sha1":fs
) -> mapM_ sha1 fs
30 where sha1 f
= do x
<- sloppyReadFilePS f
31 putStrLn $ f
++ ':' : sha1PS x
32 ("sha2":fs
) -> mapM_ sha2 fs
33 where sha2 f
= do x
<- sloppyReadFilePS f
34 putStrLn $ f
++ ':' : sha256sum x
35 _
-> fail $ unwords $ "Invalid arguments: ":args
37 sloppyReadFilePS
:: String -> IO B
.ByteString
38 sloppyReadFilePS f
= B
.readFile f `
catch`
\e
-> do putStrLn (show e
); return B
.empty