diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-08-07 12:09:53 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-08-07 12:09:53 -0400 |
commit | 6205bbac7abc919371a5e7af9e4ba1a8d70de85e (patch) | |
tree | 668f3247182d01f025ce9122f6b495def240eb71 /Entropy.hs | |
parent | 016877aa55764d14af3c16645d64fd95bf6a2da1 (diff) | |
download | keysafe-6205bbac7abc919371a5e7af9e4ba1a8d70de85e.tar.gz |
basic password entropy calculation
Diffstat (limited to 'Entropy.hs')
-rw-r--r-- | Entropy.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Entropy.hs b/Entropy.hs new file mode 100644 index 0000000..2ff28b2 --- /dev/null +++ b/Entropy.hs @@ -0,0 +1,9 @@ +module Entropy where + +import Data.List + +entropy :: String -> Double +entropy = sum . map lg' . fq' . map (fromIntegral.length) . group . sort + where + lg' c = (c * ) . logBase 2 $ 1.0 / c + fq' c = let sc = sum c in map (/ sc) c |