summaryrefslogtreecommitdiff
path: root/src/solvers
diff options
context:
space:
mode:
Diffstat (limited to 'src/solvers')
-rw-r--r--src/solvers/Challenge7.scala36
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))
+ }
+}