refactored mkHash

This commit is contained in:
Jonathan Lamothe 2019-01-01 22:45:03 -05:00
parent f305822ae1
commit cdff8c8917
3 changed files with 4 additions and 4 deletions

View File

@ -4,6 +4,7 @@
- implemented manual saving
- added a warning when changing master password
- some code cleanup as suggested by [Stephen Paul Weber](https://github.com/singpolyma)
## 0.1.1

View File

@ -30,6 +30,7 @@ dependencies:
library:
source-dirs: src
dependencies:
- base16-bytestring
- base64-bytestring
- SHA
- text

View File

@ -59,6 +59,7 @@ import Data.Aeson
, (.=)
)
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString.Base16.Lazy as B16
import qualified Data.ByteString.Base64.Lazy as B64
import Data.Char (isUpper, isLower, isDigit, isAlphaNum, toLower)
import Data.Digest.Pure.SHA
@ -338,10 +339,7 @@ mkSeed :: String -> PWData -> B.ByteString
mkSeed pw d = toUTF8 pw `B.append` (d^.pwSalt)
mkHash :: B.ByteString -> B.ByteString
mkHash = raw . show . sha256 where
raw (x:y:xs) = read ("0x" ++ [x] ++ [y]) `B.cons` raw xs
raw [_] = error "odd number of hex digits in hash"
raw "" = B.empty
mkHash = fst . B16.decode . encodeUtf8 . T.pack . show . sha256
nextPolicy :: Char -> PWPolicy -> PWPolicy
nextPolicy x p = over pwLength pred $