Commit 423d457d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[Admin] easy password manager

parent 99f25621
Pipeline #1056 failed with stage
......@@ -93,17 +93,12 @@ printPass len = do
_ <- runStateT (showRandomKey len as') aesState -- enter loop
return ()
gargPass :: IO (Int, AESRNG)
gargPass = do
gargPassMachine :: IO (Int, AESRNG)
gargPassMachine = do
aesState <- makeSystem -- gather entropy from the system to use as the initial seed
pass <- runStateT aesRandomInt aesState -- enter loop
pure pass
gargPass' :: IO Text
gargPass' = do
aesState <- makeSystem
let (bs, _aesState') = cprgGenerate 15 aesState
return (cs $ bsToStr bs)
{-
main :: IO ()
......
......@@ -7,6 +7,8 @@ Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Easy password manager for User (easy to memorize).
-}
......@@ -17,6 +19,19 @@ import Data.List ((!!))
import Gargantext.Prelude
import System.Random
-- TODO add this as parameter to gargantext.ini
gargPassUser :: (Num a, Enum a) => a -> [b] -> IO [b]
gargPassUser = gargPassUser' 3333
gargPassUser' :: (Num a, Enum a) => Int -> a -> [b] -> IO [b]
gargPassUser' threshold size wlist
| length wlist > threshold = generatePassword size wlist
| otherwise = panic "List to short"
generatePassword :: (Num a, Enum a) => a -> [b] -> IO [b]
generatePassword size wlist = mapM (\_ -> getRandomElement wlist) [1..size]
getRandomIndex :: Foldable t => t a -> IO Int
getRandomIndex list = randomRIO (0, (length list - 1))
......@@ -25,6 +40,4 @@ getRandomElement list = do
index <- (getRandomIndex list)
pure (list !! index)
generatePassword :: (Num a, Enum a) => a -> [b] -> IO [b]
generatePassword size wlist = mapM (\_ -> getRandomElement wlist) [1..size]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment