package ixee.cryptopals.solvers import scala.io.Source import ixee.cryptopals.utils.ByteUtils._ import ixee.cryptopals.utils.StreamUtils._ import ixee.cryptopals.utils.ConversionUtils._ import ixee.cryptopals.utils.FunctionUtils._ import ixee.cryptopals.utils._ import ixee.cryptopals.utils.crypto._ import io.github.marklister.base64.Base64._ object Challenge10 { val path = "./data/10.txt" lazy val ciphertext = Source .fromFile(path) .getLines() .toSeq .mkString .toByteArray def run = { def cbcBuilder = SchemeBuilder("AES", "YELLOW SUBMARINE".asBytes) .cbc(Stream.continually(0.toByte).take(16)) val encInstance = cbcBuilder.encrypt val decInstance = cbcBuilder.decrypt val s = "fooo bar frobnicator the quick brown fox jumps over the lazy dog".asBytes println(s) val enc = encInstance.end(s) val dec = decInstance.end(enc) println(enc) println(dec) println(dec.startsWith(s)) val decInstance2 = cbcBuilder.decrypt decInstance2.end(ciphertext) } }