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) = { val padLength = blockSize - (s.length % blockSize) s + s"${padLength.toChar}" * padLength } def cbcDecryptInstance(ecbCipher: Cipher, key: SecretKeySpec): CBCCipher = { ecbCipher.init(Cipher.DECRYPT_MODE, key) new CBCCipher(ecbCipher) } }