diff options
author | iximeow <me@iximeow.net> | 2014-11-26 23:17:51 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2014-11-26 23:17:51 -0800 |
commit | 9877ccf7fe7df38f8ecc65d01e9b46a98528502f (patch) | |
tree | 328cb032b21b5bac677ad091562fbc2bfb197fae /src/utils/CryptoUtils.scala | |
parent | 91b4cfc801b7c156c231ca60aba69a8d171e9226 (diff) |
Add part of CBC mode
Diffstat (limited to 'src/utils/CryptoUtils.scala')
-rw-r--r-- | src/utils/CryptoUtils.scala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils/CryptoUtils.scala b/src/utils/CryptoUtils.scala index 5418895..2b4d38e 100644 --- a/src/utils/CryptoUtils.scala +++ b/src/utils/CryptoUtils.scala @@ -1,5 +1,9 @@ package ixee.cryptopals.utils +import ixee.cryptopals.utils.crypto.CBCCipher +import javax.crypto.Cipher +import javax.crypto.spec.SecretKeySpec + object CryptoUtils { def pkcs7pad(s: String, blockSize: Int) = { @@ -7,4 +11,8 @@ object CryptoUtils { s + s"${padLength.toChar}" * padLength } + def cbcDecryptInstance(ecbCipher: Cipher, key: SecretKeySpec): CBCCipher = { + ecbCipher.init(Cipher.DECRYPT_MODE, key) + new CBCCipher(ecbCipher) + } } |