diff options
author | iximeow <me@iximeow.net> | 2014-11-26 00:41:46 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2014-11-26 00:41:46 -0800 |
commit | 31cac438b1571ba6ced29af4997cf9f1f5c3c6b7 (patch) | |
tree | 882c5dd5346f246ad5487f0510ae182e14d42624 /src | |
parent | 8b3cc4835c4c77df9f207bd342ffd024f0f726e7 (diff) |
Challenge 7
Diffstat (limited to 'src')
-rw-r--r-- | src/solvers/Challenge7.scala | 36 |
1 files changed, 36 insertions, 0 deletions
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)) + } +} |