diff options
author | iximeow <me@iximeow.net> | 2014-11-28 03:15:21 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2014-11-28 03:15:21 -0800 |
commit | 409e8109d8076058e4f154272270a79b6844da18 (patch) | |
tree | b98297162d542506bd4eb911532b349608dfc2d7 /src/utils/crypto/SchemeBuilder.scala | |
parent | 0af5a2e4ade0b032e1ec6d25c51de2ff95dd2799 (diff) |
Refactor CBC utils
Diffstat (limited to 'src/utils/crypto/SchemeBuilder.scala')
-rw-r--r-- | src/utils/crypto/SchemeBuilder.scala | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/utils/crypto/SchemeBuilder.scala b/src/utils/crypto/SchemeBuilder.scala new file mode 100644 index 0000000..ae92062 --- /dev/null +++ b/src/utils/crypto/SchemeBuilder.scala @@ -0,0 +1,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) +} + |