-- | An occasionally pure, monadic interface to AESmoduleCodec.Crypto.AES.Monad(AES,AEST,Mode(..),Direction(..),Cryptable(..),runAEST,runAES)whereimportqualifiedCodec.Crypto.AES.IOasAESimportCodec.Crypto.AES.IO(Mode(..),Direction(..),newCtx,AESCtx)importControl.ApplicativeimportControl.Monad.ST.LazyimportControl.Monad.ReaderimportControl.Monad.WriterimportControl.Monad.UnsafeIOimportqualifiedData.ByteStringasBimportqualifiedData.ByteString.LazyasBLtypeAESTma=ReaderTAESCtx(WriterTBL.ByteStringm)atypeAESsa=AEST(STs)a-- | Run an AES computationrunAEST::MonadUnsafeIOm=>Mode->B.ByteString-- ^ The AES key - 16, 24 or 32 bytes->B.ByteString-- ^ The IV, 16 bytes->Direction->AESTma->m(a,BL.ByteString)runAESTmodekeyivdiraes=doctx<-liftUnsafeIO$newCtxmodekeyivdirrunWriterT$runReaderTaesctx-- | Run an AES computationrunAES::Mode->B.ByteString-- ^ The AES key - 16, 24 or 32 bytes->B.ByteString-- ^ The IV, 16 bytes->Direction->(foralls.AESsa)->(a,BL.ByteString)runAESmodekeyivdiraes=runST$runAESTmodekeyivdiraes-- | A class of things that can be crypted---- The crypt function returns incremental results as well as-- appending them to the result bytestring.classCryptableawherecrypt::a->AESsainstanceCryptableB.ByteStringwherecryptbs=doctx<-askcrypted<-liftUnsafeIO$AES.cryptctxbstell$BL.fromChunks[crypted]returncryptedinstanceCryptableBL.ByteStringwherecrypt(BL.toChunks->chunks)=snd<$>listen(mapM_cryptchunks)