summaryrefslogtreecommitdiff
path: root/src/utils/crypto/SchemeBuilder.scala
blob: ae920626d3e6b58bc0d43bfdf98daf10b2768751 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
package ixee.cryptopals.utils.crypto

import javax.crypto.spec.SecretKeySpec
import javax.crypto.Cipher

case class SchemeBuilder(cipherAlgo: String, private val bareKey: Seq[Byte]) {
  def cipher = Cipher.getInstance(s"$cipherAlgo/ECB/NoPadding")
  lazy val key = new SecretKeySpec(bareKey.toArray, cipherAlgo)

  def ecb = EcbBuilder(this)
  def cbc(iv: Seq[Byte]) = CbcBuilder(this, iv)
}