Skip to content

Instantly share code, notes, and snippets.

@iori-yja
Created March 15, 2015 00:41
Show Gist options
  • Save iori-yja/38297db80925652a5263 to your computer and use it in GitHub Desktop.
Save iori-yja/38297db80925652a5263 to your computer and use it in GitHub Desktop.
GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> import qualified Crypto.Random.AESCtr as C
Prelude C> C.
C.AESRNG C.make C.makeSystem
Prelude C> C.make
C.make C.makeSystem
Prelude C> c <- C.makeSystem
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package old-locale-1.0.0.6 ... linking ... done.
Loading package time-1.4.2 ... linking ... done.
Loading package unix-2.7.0.1 ... linking ... done.
Loading package byteable-0.1.1 ... linking ... done.
Loading package securemem-0.1.3 ... linking ... done.
Loading package crypto-cipher-types-0.0.9 ... linking ... done.
Loading package cipher-aes-0.2.10 ... linking ... done.
Loading package primitive-0.5.4.0 ... linking ... done.
Loading package vector-0.10.12.1 ... linking ... done.
Loading package crypto-random-0.0.8 ... linking ... done.
Loading package cprng-aes-0.6.1 ... linking ... done.
Prelude C> c
aesrng[..]
Prelude C> get
getChar getContents getLine
Prelude C> import qualified Crypto.Random
Prelude C Crypto.Random> get
getChar getContents getLine
Prelude C Crypto.Random> :t c
c :: C.AESRNG
Prelude C Crypto.Random> c
aesrng[..]
Prelude C Crypto.Random> cprgGenerate
<interactive>:8:1:
Not in scope: ‘cprgGenerate’
Perhaps you meant ‘Crypto.Random.cprgGenerate’ (imported from Crypto.Random)
Prelude C Crypto.Random> import qualified Crypto.Random as R
Prelude C Crypto.Random R> R.cprgGenerate
R.cprgGenerate R.cprgGenerateWithEntropy
Prelude C Crypto.Random R> R.cprgGenerate c
<interactive>:10:16:
Couldn't match expected type ‘Int’ with actual type ‘C.AESRNG’
In the first argument of ‘Crypto.Random.cprgGenerate’, namely ‘c’
In the expression: Crypto.Random.cprgGenerate c
Prelude C Crypto.Random R> :t R.cprg
R.cprgCreate R.cprgFork R.cprgGenerate R.cprgGenerateWithEntropy R.cprgSetReseedThreshold
Prelude C Crypto.Random R> :t R.cprgGenerate
R.cprgGenerate
:: Crypto.Random.CPRG gen =>
Int -> gen -> (Data.ByteString.Internal.ByteString, gen)
Prelude C Crypto.Random R> :t C.make
C.make C.makeSystem
Prelude C Crypto.Random R> :t C.makeSystem
C.makeSystem :: IO C.AESRNG
Prelude C Crypto.Random R> let rg = R.cprgGenerate 8
Prelude C Crypto.Random R> c <- C.makeSystem
Prelude C Crypto.Random R> rg c
("\237\GS6\155W\169\&2\200",aesrng[..])
Prelude C Crypto.Random R> rg . snd $ rg c
("\224\ETB\231\150d\224T\136",aesrng[..])
Prelude C Crypto.Random R> rg . snd $ rg c
("\224\ETB\231\150d\224T\136",aesrng[..])
Prelude C Crypto.Random R> rg . snd $ rg c
("\224\ETB\231\150d\224T\136",aesrng[..])
Prelude C Crypto.Random R> let nrg = rg . snd
Prelude C Crypto.Random R> rg c
("\237\GS6\155W\169\&2\200",aesrng[..])
Prelude C Crypto.Random R> rg c
("\237\GS6\155W\169\&2\200",aesrng[..])
Prelude C Crypto.Random R> nrg c
<interactive>:22:5:
Couldn't match expected type ‘(a0, b)’ with actual type ‘C.AESRNG’
Relevant bindings include
it :: (Data.ByteString.Internal.ByteString, b)
(bound at <interactive>:22:1)
In the first argument of ‘nrg’, namely ‘c’
In the expression: nrg c
Prelude C Crypto.Random R> rg $ nrg c
<interactive>:23:10:
Couldn't match expected type ‘(a0, b)’ with actual type ‘C.AESRNG’
Relevant bindings include
it :: (Data.ByteString.Internal.ByteString,
(Data.ByteString.Internal.ByteString, b))
(bound at <interactive>:23:1)
In the first argument of ‘nrg’, namely ‘c’
In the second argument of ‘($)’, namely ‘nrg c’
Prelude C Crypto.Random R> nrg $ rg c
("\224\ETB\231\150d\224T\136",aesrng[..])
Prelude C Crypto.Random R> nrg $ rg c
("\224\ETB\231\150d\224T\136",aesrng[..])
Prelude C Crypto.Random R> nrg . nrg $ rg c
("g\DC1F\ESC\216%\188\140",aesrng[..])
Prelude C Crypto.Random R> nrg . nrg . nrg $ rg c
("/p\ETBKJ\254}L",aesrng[..])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment