blob: 78803277defc439b3d62a1f23aed59f338e19d36 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
|
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)
}
}
|