Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext-prelude
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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-prelude
Commits
1474451e
Commit
1474451e
authored
Feb 24, 2025
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ghc964' into 'master'
Make it compile with GHC 9.6.6 See merge request
!15
parents
bb15d828
07121388
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
141 deletions
+5
-141
cabal.project
cabal.project
+1
-4
gargantext-prelude.cabal
gargantext-prelude.cabal
+1
-4
package.yaml
package.yaml
+1
-4
Machine.hs
src/Gargantext/Prelude/Crypto/Pass/Machine.hs
+0
-127
Symmetric.hs
src/Gargantext/Prelude/Crypto/Symmetric.hs
+2
-2
No files found.
cabal.project
View file @
1474451e
with-compiler: ghc-9.4.7
packages:
./
packages: .
gargantext-prelude.cabal
View file @
1474451e
...
...
@@ -53,7 +53,6 @@ library
Gargantext.Prelude.Clock
Gargantext.Prelude.Crypto.Auth
Gargantext.Prelude.Crypto.Hash
Gargantext.Prelude.Crypto.Pass.Machine
Gargantext.Prelude.Crypto.Pass.User
Gargantext.Prelude.Crypto.QRCode
Gargantext.Prelude.Crypto.Share
...
...
@@ -74,9 +73,7 @@ library
, bytestring
, clock
, containers
, cprng-aes
, crypto-random
, cryptonite
, crypton
, directory
, filepath
, formatting
...
...
package.yaml
View file @
1474451e
...
...
@@ -26,12 +26,9 @@ dependencies:
-
base >= 4.7 && < 5
-
binary
-
bytestring
-
cipher-aes
-
clock
-
containers
-
cprng-aes
-
crypto-random
-
cryptonite
-
crypton
-
directory
-
extra
-
filepath
...
...
src/Gargantext/Prelude/Crypto/Pass/Machine.hs
deleted
100644 → 0
View file @
bb15d828
{-|
Module : Gargantext.Prelude.Crypto.Pass.Machine
Description :
Copyright : (c) CNRS, 2017-Present
License : Public Domain
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Random Text generator (for machines mainly)
Thanks to
https://zuttobenkyou.wordpress.com/2011/12/23/simple-password-generation-with-haskell/
-}
{-# LANGUAGE PackageImports #-}
module
Gargantext.Prelude.Crypto.Pass.Machine
where
import
Data.List
(
nub
)
-- import System.Environment (getArgs)
-- import System.IO (hSetEcho)
import
Control.Monad.State
import
"crypto-random"
Crypto.Random
(
cprgGenerate
)
import
Crypto.Random.AESCtr
import
Data.Binary
(
decode
)
import
Prelude
import
qualified
Data.ByteString.Lazy
as
B
import
Data.ByteString
as
S
(
ByteString
,
unpack
)
import
Data.ByteString.Char8
as
C8
(
pack
)
import
Data.Char
(
chr
)
strToBS
::
String
->
S
.
ByteString
strToBS
=
C8
.
pack
bsToStr
::
S
.
ByteString
->
String
bsToStr
=
map
(
chr
.
fromEnum
)
.
S
.
unpack
keysChar
,
keysNum
,
keysPunc
,
keysCharNum
,
keysAll
,
keysHex
::
String
keysChar
=
[
'a'
..
'z'
]
++
[
'A'
..
'Z'
]
keysHex
=
[
'a'
..
'f'
]
keysNum
=
[
'0'
..
'9'
]
keysPunc
=
"`~!@#$%^&*()-_=+[{]}
\\
|;:'
\"
,<.>/? "
keysCharNum
=
keysChar
++
keysNum
keysAll
=
keysChar
++
keysNum
++
keysPunc
giveKey
::
String
->
Char
->
Int
->
Char
giveKey
keysCustom
c
n
=
extractChar
$
case
c
of
'i'
->
(
keysNum
++
keysHex
)
'j'
->
keysNum
'k'
->
keysChar
'l'
->
keysCharNum
';'
->
keysPunc
'h'
->
(
keysCharNum
++
keysCustom
)
'
\n
'
->
[
'
\n
'
]
_
->
keysAll
where
extractChar
xs
=
xs
!!
mod
n
(
length
xs
)
showRandomKey
::
Int
->
String
->
StateT
AESRNG
IO
()
showRandomKey
len
keysCustom
=
handleKey
=<<
liftIO
getChar
where
handleKey
key
=
case
key
of
'
\n
'
->
liftIO
(
putChar
'
\n
'
)
>>
showRandomKey
len
keysCustom
'q'
->
(
liftIO
$
putStrLn
"
\n
Bye!"
)
>>
return
()
_
->
mapM_
f
[
0
..
len
]
>>
(
liftIO
$
putStrLn
[]
)
>>
showRandomKey
len
keysCustom
where
f
_
=
liftIO
.
putChar
.
giveKey
keysCustom
key
.
(
\
n
->
mod
n
(
length
(
keysAll
++
keysCustom
)
-
1
))
=<<
aesRandomInt
aesRandomInt
::
StateT
AESRNG
IO
Int
aesRandomInt
=
do
aesState
<-
get
-- aesState <- liftIO makeSystem
-- let aesState = 128
let
(
bs
,
aesState'
)
=
cprgGenerate
64
aesState
put
aesState'
return
(
decode
$
B
.
fromChunks
[
bs
])
printPass
::
Int
->
IO
()
printPass
len
=
do
let
as
=
[
"alphanumeric"
,
"punctuation"
]
let
as'
=
filter
(
\
c
->
elem
c
keysAll
)
.
nub
$
unwords
as
aesState
<-
makeSystem
-- gather entropy from the system to use as the initial seed
_
<-
runStateT
(
showRandomKey
len
as'
)
aesState
-- enter loop
return
()
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
{-
main :: IO ()
main = do
hSetBuffering stdin NoBuffering -- disable buffering from STDIN
hSetBuffering stdout NoBuffering -- disable buffering from STDOUT
hSetEcho stdin False -- disable terminal echo
as <- getArgs
let as' = filter (\c -> elem c keysAll) . nub $ unwords as
mapM_ putStrLn
[ []
, "poke: 'q' quit"
, " 'j' number"
, " 'k' letter"
, " 'l' alphanumeric"
, " ';' punctuation"
, " 'h' alphanumeric" ++ (if null as' then [] else " + " ++ as')
, " 'i' hexadecimal"
, " 'ENTER' newline"
, " else any"
, []
]
aesState <- makeSystem -- gather entropy from the system to use as the initial seed
_ <- runStateT (showRandomKey as') aesState -- enter loop
return ()
-}
src/Gargantext/Prelude/Crypto/Symmetric.hs
View file @
1474451e
...
...
@@ -16,14 +16,14 @@ Portability : POSIX
module
Gargantext.Prelude.Crypto.Symmetric
where
import
"crypton
ite
"
Crypto.Cipher.AES
(
AES256
)
import
"crypton"
Crypto.Cipher.AES
(
AES256
)
import
Crypto.Cipher.Types
(
BlockCipher
(
..
),
Cipher
(
..
),
IV
,
makeIV
)
import
Crypto.Error
(
CryptoFailable
(
..
),
CryptoError
(
..
))
import
Data.ByteArray
(
ByteArray
)
import
Data.Either
import
Data.Maybe
import
Protolude
-- (IO, Int, show, (++), ($), putStrLn, panic, (<*>), (<$>), (=<<), undefined, return)
import
qualified
"crypton
ite
"
Crypto.Random.Types
as
CRT
import
qualified
"crypton"
Crypto.Random.Types
as
CRT
-- | Not required, but most general implementation
data
Key
c
a
where
...
...
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