summaryrefslogtreecommitdiff
path: root/src/solvers/Challenge10.scala
blob: abc99f95d03e534673277bb0b5c72db4f5395639 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package ixee.cryptopals.solvers

import scala.io.Source
import ixee.cryptopals.utils.ByteUtils._
import ixee.cryptopals.utils.CryptoUtils._
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 builder = SchemeBuilder("AES", "YELLOW SUBMARINE".asBytes)
      .cbc(Stream.continually(0.toByte).take(16))

    new String(cbcDecrypt(builder)(ciphertext).toArray)
  }
}