diff options
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) + } } |