From 31cac438b1571ba6ced29af4997cf9f1f5c3c6b7 Mon Sep 17 00:00:00 2001 From: iximeow Date: Wed, 26 Nov 2014 00:41:46 -0800 Subject: Challenge 7 --- src/solvers/Challenge7.scala | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/solvers/Challenge7.scala (limited to 'src') diff --git a/src/solvers/Challenge7.scala b/src/solvers/Challenge7.scala new file mode 100644 index 0000000..ee1745a --- /dev/null +++ b/src/solvers/Challenge7.scala @@ -0,0 +1,36 @@ +package ixee.cryptopals.solvers + +import scala.io.Source +import ixee.cryptopals.utils.ByteUtils._ +import ixee.cryptopals.utils.ConversionUtils._ +import ixee.cryptopals.utils.FunctionUtils._ +import ixee.cryptopals.utils._ +import io.github.marklister.base64.Base64._ +import javax.crypto.Cipher +import javax.crypto.spec.SecretKeySpec + +object Challenge7 { + val path = "./data/7.txt" + + lazy val ciphertext = + Source + .fromFile(path) + .getLines() + .toSeq + .flatten + .mkString + .toByteArray + + val key = new SecretKeySpec( + "YELLOW SUBMARINE".asBytes.toArray, + "AES" + ) + + def run = { + val cipher = Cipher.getInstance( + "AES/ECB/PKCS5Padding" + ) + cipher.init(Cipher.DECRYPT_MODE, key) + new String(cipher.doFinal(ciphertext)) + } +} -- cgit v1.1