2018-12-26 14:38:42 -05:00
|
|
|
{-
|
|
|
|
|
|
|
|
passman
|
2021-01-05 21:08:41 -05:00
|
|
|
Copyright (C) 2018-2021 Jonathan Lamothe
|
2020-12-14 22:41:24 -05:00
|
|
|
<jonathan@jlamothe.net>
|
2018-12-26 14:38:42 -05:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this program. If not, see
|
|
|
|
<https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
|
2018-12-29 14:01:32 -05:00
|
|
|
module Types (Status (Status), gen, dbPath, masterPass, database) where
|
2018-12-26 14:38:42 -05:00
|
|
|
|
2021-01-05 21:22:41 -05:00
|
|
|
import Lens.Micro (set, (^.))
|
|
|
|
import Lens.Micro.TH (makeLenses)
|
2023-05-02 17:27:58 -04:00
|
|
|
import System.Random (RandomGen (genWord64, split), StdGen)
|
2018-12-26 14:38:42 -05:00
|
|
|
|
|
|
|
import Password
|
|
|
|
|
|
|
|
data Status = Status
|
|
|
|
{ _gen :: StdGen
|
|
|
|
, _masterPass :: String
|
2018-12-29 14:01:32 -05:00
|
|
|
, _dbPath :: FilePath
|
2018-12-26 14:38:42 -05:00
|
|
|
, _database :: PWDatabase
|
|
|
|
}
|
|
|
|
|
|
|
|
makeLenses ''Status
|
|
|
|
|
|
|
|
instance RandomGen Status where
|
2023-05-02 17:27:58 -04:00
|
|
|
genWord64 s = (x, s') where
|
|
|
|
(x, g') = genWord64 g
|
2018-12-26 14:38:42 -05:00
|
|
|
s' = set gen g' s
|
|
|
|
g = s^.gen
|
|
|
|
split s = (s1, s2) where
|
|
|
|
s1 = set gen g1 s
|
|
|
|
s2 = set gen g2 s
|
|
|
|
(g1, g2) = split g
|
|
|
|
g = s^.gen
|
|
|
|
|
|
|
|
--jl
|