Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
423d457d
Commit
423d457d
authored
Sep 11, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Admin] easy password manager
parent
99f25621
Pipeline
#1056
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
Machine.hs
src/Gargantext/Prelude/Crypto/Pass/Machine.hs
+2
-7
User.hs
src/Gargantext/Prelude/Crypto/Pass/User.hs
+15
-2
No files found.
src/Gargantext/Prelude/Crypto/Pass/Machine.hs
View file @
423d457d
...
...
@@ -93,17 +93,12 @@ printPass len = do
_
<-
runStateT
(
showRandomKey
len
as'
)
aesState
-- enter loop
return
()
gargPass
::
IO
(
Int
,
AESRNG
)
gargPass
=
do
gargPass
Machine
::
IO
(
Int
,
AESRNG
)
gargPass
Machine
=
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 ()
...
...
src/Gargantext/Prelude/Crypto/Pass/User.hs
View file @
423d457d
...
...
@@ -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
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment