7 Commits
0.1.1 ... 0.2

Author SHA1 Message Date
Jonathan Lamothe
412c8312b0 version 0.2 2019-01-01 23:03:09 -05:00
Jonathan Lamothe
012486c045 handle empty input string in mkPass 2019-01-01 22:50:16 -05:00
Jonathan Lamothe
cdff8c8917 refactored mkHash 2019-01-01 22:45:03 -05:00
Jonathan Lamothe
f305822ae1 whitespace fix 2019-01-01 22:25:25 -05:00
Jonathan Lamothe
7cf0b34078 warn when changing master password 2019-01-01 21:15:09 -05:00
Jonathan Lamothe
191be38fbe implemented manual saving 2019-01-01 21:02:52 -05:00
Jonathan Lamothe
f2ae7bca76 fixed changelog 2019-01-01 04:57:24 -05:00
4 changed files with 26 additions and 15 deletions

View File

@@ -1,6 +1,12 @@
# Changelog for passman
## Unreleased changes
## 0.2
- 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
- corrected a bug that was causing the pwGenerate function to hang occasionally.
- this may cause some passwords to be generated differently

View File

@@ -63,6 +63,7 @@ mainMenu =
[ ( "add a password", addPassword )
, ( "view/edit a password", viewEditMenu )
, ( "change master password", changeMasterPass )
, ( "save manually", save >> mainMenu )
, ( "lock session", lockSession )
, ( "quit", quit )
]
@@ -93,9 +94,13 @@ viewEditMenu = menu "View/Edit Password"
changeMasterPass :: S.StateT Status IO ()
changeMasterPass = do
req (confirm $
"\nWARNING: Changing your master password will change all of your saved passwords.\n" ++
"Are you sure you would like to proceed?") >>= flip when
(do
oldP <- S.gets $ view masterPass
newP <- req $ reqDefault getMasterPass oldP
S.modify $ set masterPass newP
S.modify $ set masterPass newP)
mainMenu
lockSession :: S.StateT Status IO ()

View File

@@ -1,5 +1,5 @@
name: passman
version: 0.1.1
version: 0.2
github: "jlamothe/passman"
license: LGPL-3
author: "Jonathan Lamothe"
@@ -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
@@ -322,10 +323,11 @@ isSpecial :: Char -> Bool
isSpecial = not . isAlphaNum
mkPass :: String -> PWPolicy -> String
mkPass (x:xs) p = let p' = nextPolicy x p in
if p^.pwLength <= 0
mkPass [] _ = "" -- this should never happen
mkPass (x:xs) p = if p^.pwLength <= 0
then ""
else if validatePWPolicy p'
else let p' = nextPolicy x p in
if validatePWPolicy p'
then x : mkPass xs p'
else mkPass xs p
@@ -338,10 +340,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 $